/* * This file is subject to the terms and conditions of the GNU General Public * License. See the file "COPYING" in the main directory of this archive * for more details. * * SNI specific PCI support for RM200/RM300. */ #include #include #include #include #include #include #include #ifdef CONFIG_PCI extern inline u32 mkaddr(unsigned char bus, unsigned char dev_fn, unsigned char where) { return (((bus & 0xff) << 0x10) | ((dev_fn & 0xff) << 0x08) | ((where & 0xfc))); } static unsigned long sni_rm200_pcibios_fixup (unsigned long memory_start, unsigned long memory_end) { /* I guess it's ok to do exactly nothing. */ return memory_start; } static int sni_rm200_pcibios_read_config_byte (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned char *val) { u32 res; *(volatile u32 *)PCIMT_CONFIG_ADDRESS = mkaddr(bus, dev_fn, where); res = *(volatile u32 *)PCIMT_CONFIG_DATA; res = le32_to_cpu(res); *val = res; return PCIBIOS_SUCCESSFUL; } static int sni_rm200_pcibios_read_config_word (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned short *val) { u32 res; if (where & 1) return PCIBIOS_BAD_REGISTER_NUMBER; *(volatile u32 *)PCIMT_CONFIG_ADDRESS = mkaddr(bus, dev_fn, where); res = *(volatile u32 *)PCIMT_CONFIG_DATA; res = le32_to_cpu(res); *val = res; return PCIBIOS_SUCCESSFUL; } static int sni_rm200_pcibios_read_config_dword (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned int *val) { u32 res; if (where & 3) return PCIBIOS_BAD_REGISTER_NUMBER; *(volatile u32 *)PCIMT_CONFIG_ADDRESS = mkaddr(bus, dev_fn, where); res = *(volatile u32 *)PCIMT_CONFIG_DATA; res = le32_to_cpu(res); *val = res; return PCIBIOS_SUCCESSFUL; } static int sni_rm200_pcibios_write_config_byte (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned char val) { /* To do */ return PCIBIOS_SUCCESSFUL; } static int sni_rm200_pcibios_write_config_word (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned short val) { /* To do */ return PCIBIOS_SUCCESSFUL; } static int sni_rm200_pcibios_write_config_dword (unsigned char bus, unsigned char dev_fn, unsigned char where, unsigned int val) { if (where & 3) return PCIBIOS_BAD_REGISTER_NUMBER; *(volatile u32 *)PCIMT_CONFIG_ADDRESS = mkaddr(bus, dev_fn, where); *(volatile u32 *)PCIMT_CONFIG_DATA = le32_to_cpu(val); return PCIBIOS_SUCCESSFUL; } unsigned long sni_rm200_pcibios_init(unsigned long memory_start, unsigned long memory_end) { _pcibios_fixup = sni_rm200_pcibios_fixup; _pcibios_read_config_byte = sni_rm200_pcibios_read_config_byte; _pcibios_read_config_word = sni_rm200_pcibios_read_config_word; _pcibios_read_config_dword = sni_rm200_pcibios_read_config_dword; _pcibios_write_config_byte = sni_rm200_pcibios_write_config_byte; _pcibios_write_config_word = sni_rm200_pcibios_write_config_word; _pcibios_write_config_dword = sni_rm200_pcibios_write_config_dword; return memory_start; } #endif /* CONFIG_PCI */