From 83f34df4e7c8794a5a81ede663fe184f4201308a Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Mon, 15 Oct 2007 19:34:36 +1000 Subject: Add dcr_host_t.base in dcr_read()/dcr_write() Now that all users of dcr_read()/dcr_write() add the dcr_host_t.base, we can save them the trouble and do it in dcr_read()/dcr_write(). As some background to why we just went through all this jiggery-pokery, benh sayeth: Initially the goal of the dcr_read/dcr_write routines was to operate like mfdcr/mtdcr which take absolute DCR numbers. The reason is that on 4xx hardware, indirect DCR access is a pain (goes through a table of instructions) and it's useful to have the compiler resolve an absolute DCR inline. We decided that wasn't worth the API bastardisation since most places where absolute DCR values are used are low level 4xx-only code which may as well continue using mfdcr/mtdcr, while the new API is designed for device "instances" that can exist on 4xx and Axon type platforms and may be located at variable DCR offsets. Signed-off-by: Michael Ellerman Signed-off-by: Jeff Garzik --- arch/powerpc/platforms/cell/axon_msi.c | 4 ++-- arch/powerpc/sysdev/mpic.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'arch') diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c index 1245b2f517b..aca15007a01 100644 --- a/arch/powerpc/platforms/cell/axon_msi.c +++ b/arch/powerpc/platforms/cell/axon_msi.c @@ -77,12 +77,12 @@ static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val) { pr_debug("axon_msi: dcr_write(0x%x, 0x%x)\n", val, dcr_n); - dcr_write(msic->dcr_host, msic->dcr_host.base + dcr_n, val); + dcr_write(msic->dcr_host, dcr_n, val); } static u32 msic_dcr_read(struct axon_msic *msic, unsigned int dcr_n) { - return dcr_read(msic->dcr_host, msic->dcr_host.base + dcr_n); + return dcr_read(msic->dcr_host, dcr_n); } static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc) diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index 893e65439e8..e47938899a9 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c @@ -156,7 +156,7 @@ static inline u32 _mpic_read(enum mpic_reg_type type, switch(type) { #ifdef CONFIG_PPC_DCR case mpic_access_dcr: - return dcr_read(rb->dhost, rb->dhost.base + reg); + return dcr_read(rb->dhost, reg); #endif case mpic_access_mmio_be: return in_be32(rb->base + (reg >> 2)); @@ -173,7 +173,7 @@ static inline void _mpic_write(enum mpic_reg_type type, switch(type) { #ifdef CONFIG_PPC_DCR case mpic_access_dcr: - return dcr_write(rb->dhost, rb->dhost.base + reg, value); + return dcr_write(rb->dhost, reg, value); #endif case mpic_access_mmio_be: return out_be32(rb->base + (reg >> 2), value); -- cgit v1.2.3-18-g5258 From cdbd3865acc2e98a349b41d130985e6f5f2dfc19 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Mon, 15 Oct 2007 19:34:37 +1000 Subject: Use dcr_host_t.base in dcr_unmap() With the base stored in dcr_host_t, there's no need for callers to pass the dcr_n into dcr_unmap(). In fact this removes the possibility of them passing the incorrect value, which would then be iounmap()'ed. Signed-off-by: Michael Ellerman Signed-off-by: Jeff Garzik --- arch/powerpc/sysdev/dcr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'arch') diff --git a/arch/powerpc/sysdev/dcr.c b/arch/powerpc/sysdev/dcr.c index ab11c0b2902..427027c7ea0 100644 --- a/arch/powerpc/sysdev/dcr.c +++ b/arch/powerpc/sysdev/dcr.c @@ -126,13 +126,13 @@ dcr_host_t dcr_map(struct device_node *dev, unsigned int dcr_n, } EXPORT_SYMBOL_GPL(dcr_map); -void dcr_unmap(dcr_host_t host, unsigned int dcr_n, unsigned int dcr_c) +void dcr_unmap(dcr_host_t host, unsigned int dcr_c) { dcr_host_t h = host; if (h.token == NULL) return; - h.token += dcr_n * h.stride; + h.token += host.base * h.stride; iounmap(h.token); h.token = NULL; } -- cgit v1.2.3-18-g5258 From 2843e7f7d6ffd61da6fe1503eb42c25fa33fbfee Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Mon, 15 Oct 2007 19:34:38 +1000 Subject: Remove msic_dcr_read() in axon_msi.c msic_dcr_read() doesn't really do anything useful, just replace it with direct calls to dcr_read(). Signed-off-by: Michael Ellerman Signed-off-by: Jeff Garzik --- arch/powerpc/platforms/cell/axon_msi.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'arch') diff --git a/arch/powerpc/platforms/cell/axon_msi.c b/arch/powerpc/platforms/cell/axon_msi.c index aca15007a01..095988f13bf 100644 --- a/arch/powerpc/platforms/cell/axon_msi.c +++ b/arch/powerpc/platforms/cell/axon_msi.c @@ -80,18 +80,13 @@ static void msic_dcr_write(struct axon_msic *msic, unsigned int dcr_n, u32 val) dcr_write(msic->dcr_host, dcr_n, val); } -static u32 msic_dcr_read(struct axon_msic *msic, unsigned int dcr_n) -{ - return dcr_read(msic->dcr_host, dcr_n); -} - static void axon_msi_cascade(unsigned int irq, struct irq_desc *desc) { struct axon_msic *msic = get_irq_data(irq); u32 write_offset, msi; int idx; - write_offset = msic_dcr_read(msic, MSIC_WRITE_OFFSET_REG); + write_offset = dcr_read(msic->dcr_host, MSIC_WRITE_OFFSET_REG); pr_debug("axon_msi: original write_offset 0x%x\n", write_offset); /* write_offset doesn't wrap properly, so we have to mask it */ @@ -306,7 +301,7 @@ static int axon_msi_notify_reboot(struct notifier_block *nb, list_for_each_entry(msic, &axon_msic_list, list) { pr_debug("axon_msi: disabling %s\n", msic->irq_host->of_node->full_name); - tmp = msic_dcr_read(msic, MSIC_CTRL_REG); + tmp = dcr_read(msic->dcr_host, MSIC_CTRL_REG); tmp &= ~MSIC_CTRL_ENABLE & ~MSIC_CTRL_IRQ_ENABLE; msic_dcr_write(msic, MSIC_CTRL_REG, tmp); } -- cgit v1.2.3-18-g5258 From 2de889235d0e820a6b256b834ee6a64e12fede08 Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Mon, 15 Oct 2007 19:06:20 +0900 Subject: update AU1000 get_ethernet_addr() Update AU1000 get_ethernet_addr(). Three functions were brought together in one. Signed-off-by: Yoichi Yuasa Acked-by: Ralf Baechle Signed-off-by: Jeff Garzik --- arch/mips/au1000/common/prom.c | 38 ++++++++++++++++---------------------- 1 file changed, 16 insertions(+), 22 deletions(-) (limited to 'arch') diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c index a8637cdb5b4..5d6ddf1ed7a 100644 --- a/arch/mips/au1000/common/prom.c +++ b/arch/mips/au1000/common/prom.c @@ -98,7 +98,7 @@ char *prom_getenv(char *envname) return NULL; } -inline unsigned char str2hexnum(unsigned char c) +static inline unsigned char str2hexnum(unsigned char c) { if(c >= '0' && c <= '9') return c - '0'; @@ -109,7 +109,7 @@ inline unsigned char str2hexnum(unsigned char c) return 0; /* foo */ } -inline void str2eaddr(unsigned char *ea, unsigned char *str) +static inline void str2eaddr(unsigned char *ea, unsigned char *str) { int i; @@ -124,35 +124,29 @@ inline void str2eaddr(unsigned char *ea, unsigned char *str) } } -int get_ethernet_addr(char *ethernet_addr) +int prom_get_ethernet_addr(char *ethernet_addr) { - char *ethaddr_str; + char *ethaddr_str; + char *argptr; - ethaddr_str = prom_getenv("ethaddr"); + /* Check the environment variables first */ + ethaddr_str = prom_getenv("ethaddr"); if (!ethaddr_str) { - printk("ethaddr not set in boot prom\n"); - return -1; - } - str2eaddr(ethernet_addr, ethaddr_str); - -#if 0 - { - int i; + /* Check command line */ + argptr = prom_getcmdline(); + ethaddr_str = strstr(argptr, "ethaddr="); + if (!ethaddr_str) + return -1; - printk("get_ethernet_addr: "); - for (i=0; i<5; i++) - printk("%02x:", (unsigned char)*(ethernet_addr+i)); - printk("%02x\n", *(ethernet_addr+i)); + ethaddr_str += strlen("ethaddr="); } -#endif + + str2eaddr(ethernet_addr, ethaddr_str); return 0; } +EXPORT_SYMBOL(prom_get_ethernet_addr); void __init prom_free_prom_memory(void) { } - -EXPORT_SYMBOL(prom_getcmdline); -EXPORT_SYMBOL(get_ethernet_addr); -EXPORT_SYMBOL(str2eaddr); -- cgit v1.2.3-18-g5258 From 25b31cb118f399e9996ed7a3766b86c69a6bb07e Mon Sep 17 00:00:00 2001 From: Yoichi Yuasa Date: Mon, 15 Oct 2007 19:11:24 +0900 Subject: add new prom.h for AU1x00 Add new prom.h for AU1x00. Signed-off-by: Yoichi Yuasa Acked-by: Ralf Baechle Signed-off-by: Jeff Garzik --- arch/mips/au1000/common/prom.c | 23 ++++++++++------------- arch/mips/au1000/common/setup.c | 5 +++-- arch/mips/au1000/db1x00/init.c | 10 ++++------ arch/mips/au1000/mtx-1/init.c | 6 ++---- arch/mips/au1000/pb1000/init.c | 10 ++++------ arch/mips/au1000/pb1100/init.c | 10 ++++------ arch/mips/au1000/pb1200/board_setup.c | 6 ++++-- arch/mips/au1000/pb1200/init.c | 10 ++++------ arch/mips/au1000/pb1500/init.c | 10 ++++------ arch/mips/au1000/pb1550/init.c | 10 ++++------ arch/mips/au1000/xxs1500/init.c | 10 ++++------ 11 files changed, 47 insertions(+), 63 deletions(-) (limited to 'arch') diff --git a/arch/mips/au1000/common/prom.c b/arch/mips/au1000/common/prom.c index 5d6ddf1ed7a..90d70695aa6 100644 --- a/arch/mips/au1000/common/prom.c +++ b/arch/mips/au1000/common/prom.c @@ -33,7 +33,6 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include #include #include @@ -41,18 +40,16 @@ #include -/* #define DEBUG_CMDLINE */ - -extern int prom_argc; -extern char **prom_argv, **prom_envp; - +int prom_argc; +char **prom_argv; +char **prom_envp; char * __init_or_module prom_getcmdline(void) { return &(arcs_cmdline[0]); } -void prom_init_cmdline(void) +void prom_init_cmdline(void) { char *cp; int actr; @@ -61,7 +58,7 @@ void prom_init_cmdline(void) cp = &(arcs_cmdline[0]); while(actr < prom_argc) { - strcpy(cp, prom_argv[actr]); + strcpy(cp, prom_argv[actr]); cp += strlen(prom_argv[actr]); *cp++ = ' '; actr++; @@ -70,10 +67,8 @@ void prom_init_cmdline(void) --cp; if (prom_argc > 1) *cp = '\0'; - } - char *prom_getenv(char *envname) { /* @@ -95,17 +90,19 @@ char *prom_getenv(char *envname) } env++; } + return NULL; } static inline unsigned char str2hexnum(unsigned char c) { - if(c >= '0' && c <= '9') + if (c >= '0' && c <= '9') return c - '0'; - if(c >= 'a' && c <= 'f') + if (c >= 'a' && c <= 'f') return c - 'a' + 10; - if(c >= 'A' && c <= 'F') + if (c >= 'A' && c <= 'F') return c - 'A' + 10; + return 0; /* foo */ } diff --git a/arch/mips/au1000/common/setup.c b/arch/mips/au1000/common/setup.c index b212c072612..a90d425d465 100644 --- a/arch/mips/au1000/common/setup.c +++ b/arch/mips/au1000/common/setup.c @@ -40,10 +40,11 @@ #include #include #include -#include #include -extern char * prom_getcmdline(void); +#include +#include + extern void __init board_setup(void); extern void au1000_restart(char *); extern void au1000_halt(void); diff --git a/arch/mips/au1000/db1x00/init.c b/arch/mips/au1000/db1x00/init.c index 4d7bcfc8cf7..43298fd9459 100644 --- a/arch/mips/au1000/db1x00/init.c +++ b/arch/mips/au1000/db1x00/init.c @@ -31,15 +31,13 @@ #include #include #include -#include -#include #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include +#include + +#include const char *get_system_type(void) { diff --git a/arch/mips/au1000/mtx-1/init.c b/arch/mips/au1000/mtx-1/init.c index 2aa7b2ed6a8..cdeae3212a2 100644 --- a/arch/mips/au1000/mtx-1/init.c +++ b/arch/mips/au1000/mtx-1/init.c @@ -34,13 +34,11 @@ #include #include #include + #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include const char *get_system_type(void) { diff --git a/arch/mips/au1000/pb1000/init.c b/arch/mips/au1000/pb1000/init.c index 4535f7208e1..ddccaf6997d 100644 --- a/arch/mips/au1000/pb1000/init.c +++ b/arch/mips/au1000/pb1000/init.c @@ -30,15 +30,13 @@ #include #include #include -#include -#include #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include +#include + +#include const char *get_system_type(void) { diff --git a/arch/mips/au1000/pb1100/init.c b/arch/mips/au1000/pb1100/init.c index 7ba6852de7c..c93fd39b4ab 100644 --- a/arch/mips/au1000/pb1100/init.c +++ b/arch/mips/au1000/pb1100/init.c @@ -31,15 +31,13 @@ #include #include #include -#include -#include #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include +#include + +#include const char *get_system_type(void) { diff --git a/arch/mips/au1000/pb1200/board_setup.c b/arch/mips/au1000/pb1200/board_setup.c index 2122515f79d..5dbc9868f59 100644 --- a/arch/mips/au1000/pb1200/board_setup.c +++ b/arch/mips/au1000/pb1200/board_setup.c @@ -41,8 +41,10 @@ #include #include #include -#include -#include + +#include +#include +#include #ifdef CONFIG_MIPS_PB1200 #include diff --git a/arch/mips/au1000/pb1200/init.c b/arch/mips/au1000/pb1200/init.c index 5a70029d538..c251570749e 100644 --- a/arch/mips/au1000/pb1200/init.c +++ b/arch/mips/au1000/pb1200/init.c @@ -31,15 +31,13 @@ #include #include #include -#include -#include #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include +#include + +#include const char *get_system_type(void) { diff --git a/arch/mips/au1000/pb1500/init.c b/arch/mips/au1000/pb1500/init.c index e58a9d6c502..507d4b20416 100644 --- a/arch/mips/au1000/pb1500/init.c +++ b/arch/mips/au1000/pb1500/init.c @@ -31,15 +31,13 @@ #include #include #include -#include -#include #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include +#include + +#include const char *get_system_type(void) { diff --git a/arch/mips/au1000/pb1550/init.c b/arch/mips/au1000/pb1550/init.c index fad53bf5aad..b03eee601e3 100644 --- a/arch/mips/au1000/pb1550/init.c +++ b/arch/mips/au1000/pb1550/init.c @@ -31,15 +31,13 @@ #include #include #include -#include -#include #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include +#include + +#include const char *get_system_type(void) { diff --git a/arch/mips/au1000/xxs1500/init.c b/arch/mips/au1000/xxs1500/init.c index 9f839c36f69..6532939f377 100644 --- a/arch/mips/au1000/xxs1500/init.c +++ b/arch/mips/au1000/xxs1500/init.c @@ -30,15 +30,13 @@ #include #include #include -#include -#include #include #include -int prom_argc; -char **prom_argv, **prom_envp; -extern void __init prom_init_cmdline(void); -extern char *prom_getenv(char *envname); +#include +#include + +#include const char *get_system_type(void) { -- cgit v1.2.3-18-g5258