Add support for CPM2 peripherals and 8560 eval board
cover Add support for CPM2 peripherals and 8560 eval board
The following series implements the generic cpm2 infrastructure port, mpc8560 board-specific bits, and an attempt to overhaul and get rid of some stuff moved along from the 2.4 times.
This version has refined devtree, and all the received with the initial submission comments addressed.
Paul: This is for the next merge window...
--
Sincerely, Vitaly
PATCH 1/7 POWERPC: Add cpm2 stuff support to the fsl_soc.c
This patch contains necessary modifications to support the CPM2 SoC peripherals. For the time being, those are fs_enet Ethernet driver and cpm_uart serial. Written initially to support mpc8560, it also suites to the part of the large PQ2 (more specifically, mpc8260) family.
---
arch/powerpc/sysdev/fsl_soc.c | 268 ++++++++++++++++++++++++++++++++++++++++- arch/powerpc/sysdev/fsl_soc.h | 2 2 files changed, 265 insertions(+), 5 deletions(-)
arch/powerpc/sysdev/fsl_soc.c +263 -5
@@ -3,6 +3,9 @@* * Maintained by Kumar Gala (see MAINTAINERS for contact information) * +* 2006 (c) MontaVista Software, Inc. +* Vitaly Bordug <[email protected]> +* * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your
@@ -20,14 +23,20 @@ #include <linux/module.h>#include <linux/device.h> #include <linux/platform_device.h> #include <linux/fsl_devices.h> +#include <linux/fs_enet_pd.h> +#include <linux/fs_uart_pd.h> #include <asm/system.h> #include <asm/atomic.h> #include <asm/io.h> #include <asm/irq.h> +#include <asm/time.h> #include <asm/prom.h> #include <sysdev/fsl_soc.h> #include <mm/mmu_decl.h> +#ifdef CONFIG_CPM2 +#include <asm/cpm2.h> +#endif static phys_addr_t immrbase =-1 ;
@@ -42,7 +51,9 @@ phys_addr_t get_immrbase(void)if (soc) {unsigned int size;const void *prop =get_property (soc,"reg" , &size); - immrbase =of_translate_address (soc, prop); + +if (prop) + immrbase =of_translate_address (soc, prop);of_node_put (soc); };
@@ -51,6 +62,57 @@ phys_addr_t get_immrbase(void)EXPORT_SYMBOL (get_immrbase); +#ifdef CONFIG_CPM2 + +static u32 brgfreq =-1 ; + +u32 get_brgfreq (void ) +{ +struct device_node *node; + +if (brgfreq !=-1 ) +return brgfreq; + + node =of_find_node_by_type (NULL ,"cpm" ); +if (node) { +unsigned int size; +unsigned int *prop = (unsigned int *)get_property (node,"brg-frequency" , &size); + +if (prop) + brgfreq = *prop; +of_node_put (node); + }; + +return brgfreq; +} + +EXPORT_SYMBOL (get_brgfreq); + +static u32 fs_baudrate =-1 ; + +u32 get_baudrate (void ) +{ +struct device_node *node; + +if (fs_baudrate !=-1 ) +return fs_baudrate; + + node =of_find_node_by_type (NULL ,"serial" ); +if (node) { +unsigned int size; +unsigned int *prop = (unsigned int *)get_property (node,"current-speed" , &size); + +if (prop) + fs_baudrate = *prop; +of_node_put (node); + }; + +return fs_baudrate; +} + +EXPORT_SYMBOL (get_baudrate); +#endif /* CONFIG_CPM2 */ +static int __init gfar_mdio_of_init (void ) {struct device_node *np;
@@ -85,8 +147,11 @@ static int __init gfar_mdio_of_init(void mdio_data.irq[k] =-1 ;while ((child =of_get_next_child (np, child)) !=NULL ) { -const u32 *id =get_property (child,"reg" ,NULL ); - mdio_data.irq[*id] =irq_of_parse_and_map (child,0 ); +int irq =irq_of_parse_and_map (child,0 ); +if (irq !=NO_IRQ ) { +const u32 *id =get_property (child,"reg" ,NULL ); + mdio_data.irq[*id] = irq; + } } ret =
@@ -128,7 +193,7 @@ static int __init gfar_of_init(void)const char *model;const void *mac_addr;const phandle *ph; -int n_res =1 ; +int n_res =2 ;memset (r,0 ,sizeof (r));memset (&gfar_data,0 ,sizeof (gfar_data));
@@ -159,7 +224,7 @@ static int __init gfar_of_init(void) gfar_dev =platform_device_register_simple ("fsl-gianfar" , i, &r[0 ], - n_res +1 ); + n_res);if (IS_ERR (gfar_dev)) { ret =PTR_ERR (gfar_dev);
@@ -478,3 +543,196 @@ err: }arch_initcall (fsl_usb_of_init); + +#ifdef CONFIG_CPM2 + +static const char *fcc_regs ="fcc_regs" ; +static const char *fcc_regs_c ="fcc_regs_c" ; +static const char *fcc_pram ="fcc_pram" ; +static char bus_id[9 ][BUS_ID_SIZE ]; + +static int __init fs_enet_of_init (void ) +{ +struct device_node *np; +unsigned int i; +struct platform_device *fs_enet_dev; +struct resource res; +int ret; + +for (np =NULL , i =0 ; + (np =of_find_compatible_node (np,"network" ,"fs_enet" )) !=NULL ; + i++) { +struct resource r[4 ]; +struct device_node *phy, *mdio; +struct fs_platform_info fs_enet_data; +unsigned int *id, *phy_addr; +void *mac_addr; +phandle *ph; +char *model; + +memset (r,0 ,sizeof (r)); +memset (&fs_enet_data,0 ,sizeof (fs_enet_data)); + + ret =of_address_to_resource (np,0 , &r[0 ]); +if (ret) + goto err; + r[0 ].name = fcc_regs; + + ret =of_address_to_resource (np,1 , &r[1 ]); +if (ret) + goto err; + r[1 ].name = fcc_pram; + + ret =of_address_to_resource (np,2 , &r[2 ]); +if (ret) + goto err; + r[2 ].name = fcc_regs_c; + + r[3 ].start = r[3 ].end =irq_of_parse_and_map (np,0 ); + r[3 ].flags =IORESOURCE_IRQ ; + + fs_enet_dev = +platform_device_register_simple ("fsl-cpm-fcc" , i, &r[0 ],4 ); + +if (IS_ERR (fs_enet_dev)) { + ret =PTR_ERR (fs_enet_dev); + goto err; + } + + model = (char *)get_property (np,"model" ,NULL ); +if (model ==NULL ) { + ret = -ENODEV ; + goto unreg; + } + + mac_addr = (void *)get_property (np,"mac-address" ,NULL ); +memcpy (fs_enet_data.macaddr, mac_addr,6 ); + + ph = (phandle *)get_property (np,"phy-handle" ,NULL ); + phy =of_find_node_by_phandle (*ph); + +if (phy ==NULL ) { + ret = -ENODEV ; + goto unreg; + } + + phy_addr = (u32 *)get_property (phy,"reg" ,NULL ); + fs_enet_data.phy_addr = *phy_addr; + + id = (u32 *)get_property (np,"device-id" ,NULL ); + fs_enet_data.fs_no = *id; + + mdio =of_get_parent (phy); + ret =of_address_to_resource (mdio,0 , &res); +if (ret) { +of_node_put (phy); +of_node_put (mdio); + goto unreg; + } + +if (strstr (model,"FCC" )) { +int fcc_index =fs_get_fcc_index (*id); + + fs_enet_data.dpram_offset = (u32 )cpm2_immr->im_dprambase; + fs_enet_data.rx_ring =32 ; + fs_enet_data.tx_ring =32 ; + fs_enet_data.rx_copybreak =240 ; + fs_enet_data.use_napi =0 ; + fs_enet_data.napi_weight =17 ; + fs_enet_data.mem_offset =FCC_MEM_OFFSET (fcc_index); + fs_enet_data.cp_page =CPM_CR_FCC_PAGE (fcc_index); + fs_enet_data.cp_block =CPM_CR_FCC_SBLOCK (fcc_index); + +snprintf ((char *)&bus_id[(*id)],BUS_ID_SIZE ,"%x:%02x" , + (u32 )res.start, fs_enet_data.phy_addr); + fs_enet_data.bus_id = (char *)&bus_id[(*id)]; + } + +of_node_put (phy); +of_node_put (mdio); + + ret =platform_device_add_data (fs_enet_dev, &fs_enet_data, +sizeof (struct +fs_platform_info )); +if (ret) + goto unreg; + } +return 0 ; + +unreg: +platform_device_unregister (fs_enet_dev); +err: +return ret; +} + +arch_initcall (fs_enet_of_init); + +static const char *scc_regs ="regs" ; +static const char *scc_pram ="pram" ; + +static int __init cpm_uart_of_init (void ) +{ +struct device_node *np; +unsigned int i; +struct platform_device *cpm_uart_dev; +int ret; + +for (np =NULL , i =0 ; + (np =of_find_compatible_node (np,"serial" ,"cpm_uart" )) !=NULL ; + i++) { +struct resource r[3 ]; +struct fs_uart_platform_info cpm_uart_data; +int *id; + +memset (r,0 ,sizeof (r)); +memset (&cpm_uart_data,0 ,sizeof (cpm_uart_data)); + + ret =of_address_to_resource (np,0 , &r[0 ]); +if (ret) + goto err; + + r[0 ].name = scc_regs; + + ret =of_address_to_resource (np,1 , &r[1 ]); +if (ret) + goto err; + r[1 ].name = scc_pram; + + r[2 ].start = r[2 ].end =irq_of_parse_and_map (np,0 ); + r[2 ].flags =IORESOURCE_IRQ ; + + cpm_uart_dev = +platform_device_register_simple ("fsl-cpm-scc:uart" , i, &r[0 ],3 ); + +if (IS_ERR (cpm_uart_dev)) { + ret =PTR_ERR (cpm_uart_dev); + goto err; + } + + id = (int *)get_property (np,"device-id" ,NULL ); + cpm_uart_data.fs_no = *id; + cpm_uart_data.uart_clk = ppc_proc_freq; + + cpm_uart_data.tx_num_fifo =4 ; + cpm_uart_data.tx_buf_size =32 ; + cpm_uart_data.rx_num_fifo =4 ; + cpm_uart_data.rx_buf_size =32 ; + + ret = +platform_device_add_data (cpm_uart_dev, &cpm_uart_data, +sizeof (struct +fs_uart_platform_info )); +if (ret) + goto unreg; + } + +return 0 ; + +unreg: +platform_device_unregister (cpm_uart_dev); +err: +return ret; +} + +arch_initcall (cpm_uart_of_init); +#endif /* CONFIG_CPM2 */
arch/powerpc/sysdev/fsl_soc.h +2 -0
@@ -3,6 +3,8 @@ #define __PPC_FSL_SOC_H#ifdef __KERNEL__extern phys_addr_t get_immrbase (void ); +extern u32 get_brgfreq (void ); +extern u32 get_baudrate (void );#endif #endif
PATCH 2/7 cpm_uart: make it possible to utilize from powerpc
In reply to Vitaly BordugDriver core has been updated to make use of the new powerpc OF-inspired platform devices, yet keeping compatibility to the vast board list from ppc.
---
drivers/serial/cpm_uart/cpm_uart_core.c | 11 ++++------- drivers/serial/cpm_uart/cpm_uart_cpm2.c | 13 +++++++------ include/asm-powerpc/fs_pd.h | 27 ++++++++++++++++++++++++++ include/asm-ppc/fs_pd.h | 32 +++++++++++++++++++++++++++++++ 4 files changed, 70 insertions(+), 13 deletions(-)
drivers/serial/cpm_uart/cpm_uart_core.c +4 -7
@@ -46,6 +46,7 @@ #include <linux/fs_uart_pd.h>#include <asm/io.h> #include <asm/irq.h> #include <asm/delay.h> +#include <asm/fs_pd.h> #if defined(CONFIG_SERIAL_CPM_CONSOLE ) && defined(CONFIG_MAGIC_SYSRQ )#define SUPPORT_SYSRQ
@@ -1044,11 +1045,11 @@ int cpm_uart_drv_get_platform_data(strucif (!(r =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"regs" )))return -EINVAL ; - mem = r->start; + mem = (u32 )ioremap (r->start, r->end - r->start +1 );if (!(r =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"pram" )))return -EINVAL ; - pram = r->start; + pram = (u32 )ioremap (r->start, r->end - r->start +1 );if (idx > fsid_smc2_uart) { pinfo->sccp = (scc_t *)mem;
@@ -1189,11 +1190,7 @@ static int __init cpm_uart_console_setupif (options) {uart_parse_options (options, &baud, &parity, &bits, &flow); }else { -bd_t *bd = (bd_t *) __res; - -if (bd->bi_baudrate) - baud = bd->bi_baudrate; -else +if ((baud =uart_baudrate ()) ==-1 ) baud =9600 ; }
drivers/serial/cpm_uart/cpm_uart_cpm2.c +7 -6
@@ -40,6 +40,7 @@ #include <linux/dma-mapping.h>#include <asm/io.h> #include <asm/irq.h> +#include <asm/fs_pd.h> #include <linux/serial_core.h> #include <linux/kernel.h>
@@ -266,7 +267,7 @@ #ifdef CONFIG_SERIAL_CPM_SMC1 (unsigned long )&cpm2_immr->im_smc[0 ]; cpm_uart_ports[UART_SMC1 ].smcp->smc_smcm |= (SMCM_RX |SMCM_TX ); cpm_uart_ports[UART_SMC1 ].smcp->smc_smcmr &= ~(SMCMR_REN |SMCMR_TEN ); - cpm_uart_ports[UART_SMC1 ].port.uartclk = (((bd_t *) __res)->bi_intfreq); + cpm_uart_ports[UART_SMC1 ].port.uartclk =uart_clock (); cpm_uart_port_map[cpm_uart_nr++] =UART_SMC1 ;#endif
@@ -279,7 +280,7 @@ #ifdef CONFIG_SERIAL_CPM_SMC2 (unsigned long )&cpm2_immr->im_smc[1 ]; cpm_uart_ports[UART_SMC2 ].smcp->smc_smcm |= (SMCM_RX |SMCM_TX ); cpm_uart_ports[UART_SMC2 ].smcp->smc_smcmr &= ~(SMCMR_REN |SMCMR_TEN ); - cpm_uart_ports[UART_SMC2 ].port.uartclk = (((bd_t *) __res)->bi_intfreq); + cpm_uart_ports[UART_SMC2 ].port.uartclk =uart_clock (); cpm_uart_port_map[cpm_uart_nr++] =UART_SMC2 ;#endif
@@ -293,7 +294,7 @@ #ifdef CONFIG_SERIAL_CPM_SCC1 ~(UART_SCCM_TX |UART_SCCM_RX ); cpm_uart_ports[UART_SCC1 ].sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR |SCC_GSMRL_ENT ); - cpm_uart_ports[UART_SCC1 ].port.uartclk = (((bd_t *) __res)->bi_intfreq); + cpm_uart_ports[UART_SCC1 ].port.uartclk =uart_clock (); cpm_uart_port_map[cpm_uart_nr++] =UART_SCC1 ;#endif
@@ -307,7 +308,7 @@ #ifdef CONFIG_SERIAL_CPM_SCC2 ~(UART_SCCM_TX |UART_SCCM_RX ); cpm_uart_ports[UART_SCC2 ].sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR |SCC_GSMRL_ENT ); - cpm_uart_ports[UART_SCC2 ].port.uartclk = (((bd_t *) __res)->bi_intfreq); + cpm_uart_ports[UART_SCC2 ].port.uartclk =uart_clock (); cpm_uart_port_map[cpm_uart_nr++] =UART_SCC2 ;#endif
@@ -321,7 +322,7 @@ #ifdef CONFIG_SERIAL_CPM_SCC3 ~(UART_SCCM_TX |UART_SCCM_RX ); cpm_uart_ports[UART_SCC3 ].sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR |SCC_GSMRL_ENT ); - cpm_uart_ports[UART_SCC3 ].port.uartclk = (((bd_t *) __res)->bi_intfreq); + cpm_uart_ports[UART_SCC3 ].port.uartclk =uart_clock (); cpm_uart_port_map[cpm_uart_nr++] =UART_SCC3 ;#endif
@@ -335,7 +336,7 @@ #ifdef CONFIG_SERIAL_CPM_SCC4 ~(UART_SCCM_TX |UART_SCCM_RX ); cpm_uart_ports[UART_SCC4 ].sccp->scc_gsmrl &= ~(SCC_GSMRL_ENR |SCC_GSMRL_ENT ); - cpm_uart_ports[UART_SCC4 ].port.uartclk = (((bd_t *) __res)->bi_intfreq); + cpm_uart_ports[UART_SCC4 ].port.uartclk =uart_clock (); cpm_uart_port_map[cpm_uart_nr++] =UART_SCC4 ;#endif
include/asm-powerpc/fs_pd.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* Platform information definitions. +* +* 2006 (c) MontaVista Software, Inc. +* Vitaly Bordug <[email protected]> +* +* This file is licensed under the terms of the GNU General Public License +* version 2. This program is licensed "as is" without any warranty of any +* kind, whether express or implied. +*/ + +#ifndef FS_PD_H +#define FS_PD_H +#include <sysdev/fsl_soc.h> +#include <asm/time.h> + +static inline int uart_baudrate (void ) +{ +return get_baudrate (); +} + +static inline int uart_clock (void ) +{ +return ppc_proc_freq; +} + +#endif
include/asm-ppc/fs_pd.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* Platform information definitions. +* +* 2006 (c) MontaVista Software, Inc. +* Vitaly Bordug <[email protected]> +* +* This file is licensed under the terms of the GNU General Public License +* version 2. This program is licensed "as is" without any warranty of any +* kind, whether express or implied. +*/ + +#ifndef FS_PD_H +#define FS_PD_H + +static inline int uart_baudrate (void ) +{ +int baud; +bd_t *bd = (bd_t *) __res; + +if (bd->bi_baudrate) + baud = bd->bi_baudrate; +else + baud =-1 ; +return baud; +} + +static inline int uart_clock (void ) +{ +return (((bd_t *) __res)->bi_intfreq); +} + +#endif
PATCH 3/7 POWERPC: Move generic cpm2 stuff to powerpc
In reply to Vitaly BordugThis moves the cpm2 common code and PIC stuff to the powerpc. Most of the files were just copied from ppc/, with minor tuning to make it compile, and, subsequently, work.
---
arch/powerpc/lib/Makefile | 5 + arch/powerpc/sysdev/Makefile | 5 + arch/powerpc/sysdev/cpm2_common.c | 204 +++++++++++++++++++++++++++++ arch/powerpc/sysdev/cpm2_pic.c | 256 +++++++++++++++++++++++++++++++++++++ arch/powerpc/sysdev/cpm2_pic.h | 8 + include/asm-ppc/cpm2.h | 6 + 6 files changed, 483 insertions(+), 1 deletions(-)
arch/powerpc/lib/Makefile +5 -0
@@ -20,3 +20,8 @@ ifeq ($(CONFIG_PPC64),y) obj-$(CONFIG_SMP) += locks.o obj-$(CONFIG_DEBUG_KERNEL) += sstep.o endif + +# Temporary hack until we have migrated to asm-powerpc +ifeq ($(ARCH),powerpc) +obj-$(CONFIG_CPM2) += rheap.o +endif
arch/powerpc/sysdev/Makefile +5 -0
@@ -17,3 +17,8 @@ ifeq ($(CONFIG_PPC_MERGE),y) obj-$(CONFIG_PPC_I8259) += i8259.o obj-$(CONFIG_PPC_83xx) += ipic.o endif + +# Temporary hack until we have migrated to asm-powerpc +ifeq ($(ARCH),powerpc) +obj-$(CONFIG_CPM2) += cpm2_common.o cpm2_pic.o +endif
arch/powerpc/sysdev/cpm2_common.c new file +204 -0
204 lines not on this page · raw message
arch/powerpc/sysdev/cpm2_pic.c new file +256 -0
256 lines not on this page · raw message
arch/powerpc/sysdev/cpm2_pic.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef _PPC_KERNEL_CPM2_H +#define _PPC_KERNEL_CPM2_H + +extern int cpm2_get_irq (struct pt_regs *regs); + +extern void cpm2_pic_init (struct device_node *); + +#endif /* _PPC_KERNEL_CPM2_H */
include/asm-ppc/cpm2.h +5 -1
@@ -42,6 +42,8 @@ #define CPM_CR_IDMA3_SBLOCK (0x16)#define CPM_CR_IDMA4_SBLOCK (0x17)#define CPM_CR_MCC1_SBLOCK (0x1c) +#define CPM_CR_FCC_SBLOCK (x) (x + 0x10) +#define CPM_CR_SCC1_PAGE (0x00)#define CPM_CR_SCC2_PAGE (0x01)#define CPM_CR_SCC3_PAGE (0x02)
@@ -62,6 +64,8 @@ #define CPM_CR_IDMA4_PAGE (0x0a)#define CPM_CR_MCC1_PAGE (0x07)#define CPM_CR_MCC2_PAGE (0x08) +#define CPM_CR_FCC_PAGE (x) (x + 0x04) +/* Some opcodes (there are more...later) */ #define CPM_CR_INIT_TRX ((ushort)0x0000)
@@ -1186,7 +1190,7 @@ #define PC3_DIRC1 (PC3_TXDAT)#define FCC_MEM_OFFSET (x) (CPM_FCC_SPECIAL_BASE + (x*128))#define FCC1_MEM_OFFSET FCC_MEM_OFFSET(0)#define FCC2_MEM_OFFSET FCC_MEM_OFFSET(1) -#define FCC2_MEM_OFFSET FCC_MEM_OFFSET(2) +#define FCC3_MEM_OFFSET FCC_MEM_OFFSET(2)#endif /* __CPM2__ */ #endif /* __KERNEL__ */
PATCH 4/7 POWERPC: Add support for the mpc8560 eval board
In reply to Vitaly BordugThis makes the 8560 evaluation board fully supported under arch/powerpc, as the first board with CPM2 SoC peripherals. The brand new devicetree nodes are introduced (intending to be a subset of the QuiccEngine-equipped models, with dts sources placed into the kernel according to the new convention.
Assuming all the preceding stuff applied (PAL+fs_enet related+ CPM_UART update), the both TSEC eth ,FCC Eths, and both SCC UARTs are working. The relevant drivers are still capable to drive users in ppc, which was verified with 8272ADS (SCC uart+FCC eth).
This is also verified on mpc8540 and actually make it work (PCI stuff working as well)
---
arch/powerpc/boot/dts/mpc8560ads.dts | 302 ++++++++++ arch/powerpc/configs/mpc8560_ads_defconfig | 854 ++++++++++++++++++++++++++++ arch/powerpc/platforms/85xx/Kconfig | 21 + arch/powerpc/platforms/85xx/Makefile | 1 arch/powerpc/platforms/85xx/mpc85xx_ads.c | 109 ++++ arch/powerpc/platforms/85xx/mpc85xx_ads.h | 61 ++ include/asm-powerpc/mpc85xx.h | 53 ++ 7 files changed, 1401 insertions(+), 0 deletions(-)
arch/powerpc/boot/dts/mpc8560ads.dts new file +302 -0
@@ -0,0 +1,302 @@ +/* + * MPC8560 ADS Device Tree Source + * + * Copyright 2006 Freescale Semiconductor Inc. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + */ + + +/ { + model = "MPC8560ADS"; + compatible = "MPC85xxADS"; + #address-cells = <1>; + #size-cells = <1>; + linux,phandle = <100>; + + cpus { + #cpus = <1>; + #address-cells = <1>; + #size-cells = <0>; + linux,phandle = <200>; + + PowerPC,8560@0 { + device_type = "cpu"; + reg = <0>; + d-cache-line-size = <20>; // 32 bytes + i-cache-line-size = <20>; // 32 bytes + d-cache-size = <8000>; // L1, 32K + i-cache-size = <8000>; // L1, 32K + timebase-frequency = <04ead9a0>; + bus-frequency = <13ab6680>; + clock-frequency = <312c8040>; + 32-bit; + linux,phandle = <201>; + linux,boot-cpu; + }; + }; + + memory { + device_type = "memory"; + linux,phandle = <300>; + reg = <00000000 10000000>; + }; + + soc8560@e0000000 { + #address-cells = <1>; + #size-cells = <1>; + #interrupt-cells = <2>; + device_type = "soc"; + ranges = <0 e0000000 00100000>; + reg = <e0000000 00000200>; + bus-frequency = <13ab6680>; + + mdio@24520 { + device_type = "mdio"; + compatible = "gianfar"; + reg = <24520 20>; + linux,phandle = <24520>; + #address-cells = <1>; + #size-cells = <0>; + ethernet-phy@0 { + linux,phandle = <2452000>; + interrupt-parent = <40000>; + interrupts = <35 1>; + reg = <0>; + device_type = "ethernet-phy"; + }; + ethernet-phy@1 { + linux,phandle = <2452001>; + interrupt-parent = <40000>; + interrupts = <35 1>; + reg = <1>; + device_type = "ethernet-phy"; + }; + ethernet-phy@2 { + linux,phandle = <2452002>; + interrupt-parent = <40000>; + interrupts = <37 1>; + reg = <2>; + device_type = "ethernet-phy"; + }; + ethernet-phy@3 { + linux,phandle = <2452003>; + interrupt-parent = <40000>; + interrupts = <37 1>; + reg = <3>; + device_type = "ethernet-phy"; + }; + }; + + ethernet@24000 { + device_type = "network"; + model = "TSEC"; + compatible = "gianfar"; + reg = <24000 1000>; + address = [ 00 00 0C 00 00 FD ]; + interrupts = <d 2 e 2 12 2>; + interrupt-parent = <40000>; + phy-handle = <2452000>; + }; + + ethernet@25000 { + #address-cells = <1>; + #size-cells = <0>; + device_type = "network"; + model = "TSEC"; + compatible = "gianfar"; + reg = <25000 1000>; + address = [ 00 00 0C 00 01 FD ]; + interrupts = <13 2 14 2 18 2>; + interrupt-parent = <40000>; + phy-handle = <2452001>; + }; + + pci@8000 { + linux,phandle = <8000>; + #interrupt-cells = <1>; + #size-cells = <2>; + #address-cells = <3>; + compatible = "85xx"; + device_type = "pci"; + reg = <8000 400>; + clock-frequency = <3f940aa>; + interrupt-map-mask = <f800 0 0 7>; + interrupt-map = < + + /* IDSEL 0x2 */ + 1000 0 0 1 40000 31 1 + 1000 0 0 2 40000 32 1 + 1000 0 0 3 40000 33 1 + 1000 0 0 4 40000 34 1 + + /* IDSEL 0x3 */ + 1800 0 0 1 40000 34 1 + 1800 0 0 2 40000 31 1 + 1800 0 0 3 40000 32 1 + 1800 0 0 4 40000 33 1 + + /* IDSEL 0x4 */ + 2000 0 0 1 40000 33 1 + 2000 0 0 2 40000 34 1 + 2000 0 0 3 40000 31 1 + 2000 0 0 4 40000 32 1 + + /* IDSEL 0x5 */ + 2800 0 0 1 40000 32 1 + 2800 0 0 2 40000 33 1 + 2800 0 0 3 40000 34 1 + 2800 0 0 4 40000 31 1 + + /* IDSEL 12 */ + 6000 0 0 1 40000 31 1 + 6000 0 0 2 40000 32 1 + 6000 0 0 3 40000 33 1 + 6000 0 0 4 40000 34 1 + + /* IDSEL 13 */ + 6800 0 0 1 40000 34 1 + 6800 0 0 2 40000 31 1 + 6800 0 0 3 40000 32 1 + 6800 0 0 4 40000 33 1 + + /* IDSEL 14*/ + 7000 0 0 1 40000 33 1 + 7000 0 0 2 40000 34 1 + 7000 0 0 3 40000 31 1 + 7000 0 0 4 40000 32 1 + + /* IDSEL 15 */ + 7800 0 0 1 40000 32 1 + 7800 0 0 2 40000 33 1 + 7800 0 0 3 40000 34 1 + 7800 0 0 4 40000 31 1 + + /* IDSEL 18 */ + 9000 0 0 1 40000 31 1 + 9000 0 0 2 40000 32 1 + 9000 0 0 3 40000 33 1 + 9000 0 0 4 40000 34 1 + + /* IDSEL 19 */ + 9800 0 0 1 40000 34 1 + 9800 0 0 2 40000 31 1 + 9800 0 0 3 40000 32 1 + 9800 0 0 4 40000 33 1 + + /* IDSEL 20 */ + a000 0 0 1 40000 33 1 + a000 0 0 2 40000 34 1 + a000 0 0 3 40000 31 1 + a000 0 0 4 40000 32 1 + + /* IDSEL 21 */ + a800 0 0 1 40000 32 1 + a800 0 0 2 40000 33 1 + a800 0 0 3 40000 34 1 + a800 0 0 4 40000 31 1>; + + interrupt-parent = <40000>; + interrupts = <42 0>; + bus-range = <0 0>; + ranges = <02000000 0 80000000 80000000 0 20000000 + 01000000 0 00000000 e2000000 0 01000000>; + }; + + pic@40000 { + linux,phandle = <40000>; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <2>; + reg = <40000 20100>; + built-in; + device_type = "open-pic"; + }; + + cpm@e0000000 { + linux,phandle = <e0000000>; + #address-cells = <1>; + #size-cells = <1>; + #interrupt-cells = <2>; + device_type = "cpm"; + model = "CPM2"; + ranges = <0 0 c0000>; + reg = <80000 40000>; + command-proc = <919c0>; + brg-frequency = <9d5b340>; + + pic@90c00 { + linux,phandle = <90c00>; + interrupt-controller; + #address-cells = <0>; + #interrupt-cells = <2>; + interrupts = <1e 0>; + interrupt-parent = <40000>; + reg = <90c00 80>; + built-in; + device_type = "cpm-pic"; + }; + + scc@91a00 { + device_type = "serial"; + compatible = "cpm_uart"; + model = "SCC"; + device-id = <2>; + reg = <91a00 20 88000 100>; + clock-setup = <00ffffff 0>; + rx-clock = <1>; + tx-clock = <1>; + current-speed = <1c200>; + interrupts = <64 1>; + interrupt-parent = <90c00>; + }; + + scc@91a20 { + device_type = "serial"; + compatible = "cpm_uart"; + model = "SCC"; + device-id = <3>; + reg = <91a20 20 88100 100>; + clock-setup = <ff00ffff 90000>; + rx-clock = <2>; + tx-clock = <2>; + current-speed = <1c200>; + interrupts = <65 1>; + interrupt-parent = <90c00>; + }; + + fcc@91320 { + device_type = "network"; + compatible = "fs_enet"; + model = "FCC"; + device-id = <3>; + reg = <91320 20 88500 100 913a0 30>; + mac-address = [ 00 00 0C 00 02 FD ]; + clock-setup = <ff00ffff 250000>; + rx-clock = <15>; + tx-clock = <16>; + interrupts = <5d 1>; + interrupt-parent = <90c00>; + phy-handle = <2452002>; + }; + + fcc@91340 { + device_type = "network"; + compatible = "fs_enet"; + model = "FCC"; + device-id = <4>; + reg = <91340 20 88600 100 913d0 30>; + mac-address = [ 00 00 0C 00 03 FD ]; + clock-setup = <ffff00ff 3700>; + rx-clock = <17>; + tx-clock = <18>; + interrupts = <5e 1>; + interrupt-parent = <90c00>; + phy-handle = <2452003>; + }; + }; + }; +};
arch/powerpc/configs/mpc8560_ads_defconfig new file +854 -0
854 lines not on this page · raw message
arch/powerpc/platforms/85xx/Kconfig +21 -0
@@ -11,6 +11,12 @@ config MPC8540_ADS help This option enables support for the MPC 8540 ADS board +config MPC8560_ADS + bool "Freescale MPC8560 ADS" + select DEFAULT_UIMAGE + help + This option enables support for the MPC 8560 ADS board + config MPC85xx_CDS bool "Freescale MPC85xx CDS" select DEFAULT_UIMAGE
@@ -25,6 +31,11 @@ config MPC8540 select PPC_INDIRECT_PCI default y if MPC8540_ADS || MPC85xx_CDS +config MPC8560 + bool + select PPC_INDIRECT_PCI + default y if MPC8560_ADS + config PPC_INDIRECT_PCI_BE bool depends on PPC_85xx
@@ -34,4 +45,14 @@ config MPIC bool default y +config CPM2 + bool + depends on MPC8560 + default y + help + The CPM2 (Communications Processor Module) is a coprocessor on + embedded CPUs made by Motorola. Selecting this option means that + you wish to build a kernel for a machine with a CPM2 coprocessor + on it. + endmenu
arch/powerpc/platforms/85xx/Makefile +1 -0
@@ -3,4 +3,5 @@ # Makefile for the PowerPC 85xx linux ke # obj-$(CONFIG_PPC_85xx) += misc.o pci.o obj-$(CONFIG_MPC8540_ADS) += mpc85xx_ads.o +obj-$(CONFIG_MPC8560_ADS) += mpc85xx_ads.o obj-$(CONFIG_MPC85xx_CDS) += mpc85xx_cds.o
arch/powerpc/platforms/85xx/mpc85xx_ads.c +109 -0
144 lines not on this page · raw message
arch/powerpc/platforms/85xx/mpc85xx_ads.h new file +61 -0
61 lines not on this page · raw message
include/asm-powerpc/mpc85xx.h new file +53 -0
53 lines not on this page · raw message
PATCH 5/7 POWERPC: Get rid of remapping the whole immr
In reply to Vitaly BordugThe stuff below cleans up the code attempting to remap the whole cpm2_immr early, as well as places happily assuming that fact. This is more like the 2.4 legacy stuff, and is at least confusing and unclear now.
To keep the world comfortable, a new mechanism is introduced: before accessing specific immr register/register set, one needs to map it, using cpm2_map(<reg>), for instance, access to CPM command register will look like
volatile cpm_cpm2_t *cp = cpm2_map(im_cpm);
keeping the code clear, yet without "already defined somewhere" cpm2_immr.
So far, unmapping code is not implemented, but it's not a big deal to add it, if the whole idea makes sense.
---
arch/powerpc/sysdev/cpm2_common.c | 19 +++-- arch/powerpc/sysdev/cpm2_pic.c | 28 +++---- arch/powerpc/sysdev/cpm2_pic.h | 2 arch/powerpc/sysdev/fsl_soc.c | 2 drivers/serial/cpm_uart/cpm_uart_cpm2.c | 130 +++++++++++++++++++++---------- drivers/serial/cpm_uart/cpm_uart_cpm2.h | 2 include/asm-powerpc/fs_pd.h | 18 ++++ include/asm-ppc/cpm2.h | 4 + include/asm-ppc/fs_pd.h | 4 + 9 files changed, 145 insertions(+), 64 deletions(-)
arch/powerpc/sysdev/cpm2_common.c +14 -5
@@ -44,6 +44,7 @@ cpm_cpm2_t *cpmp; /* Pointer to comm pr* the communication processor devices. */ cpm2_map_t *cpm2_immr; +intctl_cpm2_t *cpm2_intctl;#define CPM_MAP_SIZE (0x40000)/* 256k - the PQ3 reserve this amount of space for CPM as it is larger
@@ -53,6 +54,7 @@ voidcpm2_reset (void) { cpm2_immr = (cpm2_map_t *)ioremap (CPM_MAP_ADDR ,CPM_MAP_SIZE ); + cpm2_intctl =cpm2_map (im_intctl);/* Reclaim the DP memory for our use. */
@@ -87,14 +89,16 @@ cpm_setbrg(uint brg, uint rate)/* This is good enough to get SMCs running..... */ if (brg <4 ) { - bp = (uint *)&cpm2_immr->im_brgc1; + bp =cpm2_map_size (im_brgc1,16 ); }else { - bp = (uint *)&cpm2_immr->im_brgc5; + bp =cpm2_map_size (im_brgc5,16 ); brg -=4 ; } bp += brg; *bp = ((BRG_UART_CLK / rate) <<1 ) |CPM_BRG_EN ; + +cpm2_unmap (bp); }/* This function is used to set high speed synchronous baud rate
@@ -106,16 +110,18 @@ cpm2_fastbrg(uint brg, uint rate, int divolatile uint *bp;if (brg <4 ) { - bp = (uint *)&cpm2_immr->im_brgc1; + bp =cpm2_map_size (im_brgc1,16 ); }else { - bp = (uint *)&cpm2_immr->im_brgc5; + bp =cpm2_map_size (im_brgc5,16 ); brg -=4 ; } bp += brg; *bp = ((BRG_INT_CLK / rate) <<1 ) |CPM_BRG_EN ;if (div16) *bp |=CPM_BRG_DIV16 ; + +cpm2_unmap (bp); }/*
@@ -126,11 +132,14 @@ static spinlock_t cpm_dpmem_lock;* until the memory subsystem goes up... */ static rh_block_t cpm_boot_dpmem_rh_block[16 ];static rh_info_t cpm_dpmem_info; +static u8 * im_dprambase;static void cpm2_dpinit (void ) {spin_lock_init (&cpm_dpmem_lock); + im_dprambase =ioremap (CPM_MAP_ADDR ,CPM_DATAONLY_BASE +CPM_DATAONLY_SIZE ); +/* initialize the info header */ rh_init(&cpm_dpmem_info, 1, sizeof(cpm_boot_dpmem_rh_block) /
@@ -199,6 +208,6 @@ EXPORT_SYMBOL(cpm_dpdump);void *cpm_dpram_addr (uint offset) { -return (void *)&cpm2_immr->im_dprambase[offset]; +return (void *)(im_dprambase + offset); }EXPORT_SYMBOL (cpm_dpram_addr);
arch/powerpc/sysdev/cpm2_pic.c +14 -14
@@ -76,7 +76,7 @@ static void cpm2_mask_irq(unsigned int i bit = irq_to_siubit[irq_nr]; word = irq_to_siureg[irq_nr]; - simr = &(cpm2_immr->im_intctl.ic_simrh); + simr = &(cpm2_intctl->ic_simrh); ppc_cached_irq_mask[word] &= ~(1 << bit); simr[word] = ppc_cached_irq_mask[word]; }
@@ -91,7 +91,7 @@ static void cpm2_unmask_irq(unsigned int bit = irq_to_siubit[irq_nr]; word = irq_to_siureg[irq_nr]; - simr = &(cpm2_immr->im_intctl.ic_simrh); + simr = &(cpm2_intctl->ic_simrh); ppc_cached_irq_mask[word] |=1 << bit; simr[word] = ppc_cached_irq_mask[word]; }
@@ -106,8 +106,8 @@ static void cpm2_mask_and_ack(unsigned i bit = irq_to_siubit[irq_nr]; word = irq_to_siureg[irq_nr]; - simr = &(cpm2_immr->im_intctl.ic_simrh); - sipnr = &(cpm2_immr->im_intctl.ic_sipnrh); + simr = &(cpm2_intctl->ic_simrh); + sipnr = &(cpm2_intctl->ic_sipnrh); ppc_cached_irq_mask[word] &= ~(1 << bit); simr[word] = ppc_cached_irq_mask[word]; sipnr[word] =1 << bit;
@@ -125,7 +125,7 @@ static void cpm2_end_irq(unsigned int ir bit = irq_to_siubit[irq_nr]; word = irq_to_siureg[irq_nr]; - simr = &(cpm2_immr->im_intctl.ic_simrh); + simr = &(cpm2_intctl->ic_simrh); ppc_cached_irq_mask[word] |=1 << bit; simr[word] = ppc_cached_irq_mask[word];/*
@@ -152,7 +152,7 @@ int cpm2_get_irq(struct pt_regs *regs)/* For CPM2, read the SIVEC register and shift the bits down * to get the irq number. */ - bits = cpm2_immr->im_intctl.ic_sivec; + bits = cpm2_intctl->ic_sivec; irq = bits >>26 ;if (irq ==0 )
@@ -223,26 +223,26 @@ void cpm2_pic_init(struct device_node *n/* Mask out everything */ - cpm2_immr->im_intctl.ic_simrh =0x00000000 ; - cpm2_immr->im_intctl.ic_simrl =0x00000000 ; + cpm2_intctl->ic_simrh =0x00000000 ; + cpm2_intctl->ic_simrl =0x00000000 ;wmb ();/* Ack everything */ - cpm2_immr->im_intctl.ic_sipnrh =0xffffffff ; - cpm2_immr->im_intctl.ic_sipnrl =0xffffffff ; + cpm2_intctl->ic_sipnrh =0xffffffff ; + cpm2_intctl->ic_sipnrl =0xffffffff ;wmb ();/* Dummy read of the vector */ - i = cpm2_immr->im_intctl.ic_sivec; + i = cpm2_intctl->ic_sivec;rmb ();/* Initialize the default interrupt mapping priorities, * in case the boot rom changed something on us. */ - cpm2_immr->im_intctl.ic_sicr =0 ; - cpm2_immr->im_intctl.ic_scprrh =0x05309770 ; - cpm2_immr->im_intctl.ic_scprrl =0x05309770 ; + cpm2_intctl->ic_sicr =0 ; + cpm2_intctl->ic_scprrh =0x05309770 ; + cpm2_intctl->ic_scprrl =0x05309770 ;/* create a legacy host */ if (node)
arch/powerpc/sysdev/cpm2_pic.h +2 -0
@@ -1,6 +1,8 @@#ifndef _PPC_KERNEL_CPM2_H#define _PPC_KERNEL_CPM2_H +extern intctl_cpm2_t *cpm2_intctl; +extern int cpm2_get_irq (struct pt_regs *regs);extern void cpm2_pic_init (struct device_node *);
arch/powerpc/sysdev/fsl_soc.c +1 -1
@@ -633,7 +633,7 @@ static int __init fs_enet_of_init(void)if (strstr (model,"FCC" )) {int fcc_index =fs_get_fcc_index (*id); - fs_enet_data.dpram_offset = (u32 )cpm2_immr->im_dprambase; + fs_enet_data.dpram_offset = (u32 )cpm_dpram_addr (0 ); fs_enet_data.rx_ring =32 ; fs_enet_data.tx_ring =32 ; fs_enet_data.rx_copybreak =240 ;
drivers/serial/cpm_uart/cpm_uart_cpm2.c +87 -43
256 lines not on this page · raw message
drivers/serial/cpm_uart/cpm_uart_cpm2.h +1 -1
@@ -40,6 +40,6 @@ static inline void cpm_set_smc_fcr(volat up->smc_tfcr = CPMFCR_GBL | CPMFCR_EB; } -#define DPRAM_BASE ((unsigned char *)&cpm2_immr->im_dprambase[0]) +#define DPRAM_BASE ((unsigned char *)cpm_dpram_addr(0))#endif
include/asm-powerpc/fs_pd.h +18 -0
@@ -11,6 +11,7 @@#ifndef FS_PD_H #define FS_PD_H +#include <asm/cpm2.h> #include <sysdev/fsl_soc.h> #include <asm/time.h>
@@ -24,4 +25,21 @@ static inline int uart_clock(void) return ppc_proc_freq; } +#define cpm2_map (member) \ +({ \ + u32 offset = offsetof(cpm2_map_t, member); \ + void *addr = ioremap (CPM_MAP_ADDR + offset, \ + sizeof( ((cpm2_map_t*)0)->member)); \ + addr; \ +}) + +#define cpm2_map_size (member, size) \ +({ \ + u32 offset = offsetof(cpm2_map_t, member); \ + void *addr = ioremap (CPM_MAP_ADDR + offset, size); \ + addr; \ +}) + +#define cpm2_unmap (addr) iounmap(addr) +#endif
include/asm-ppc/cpm2.h +4 -0
@@ -177,6 +177,10 @@ #define PROFF_RAND ((uint)0x8af8)#define PROFF_I2C_BASE ((uint)0x8afc)#define PROFF_IDMA4_BASE ((uint)0x8afe) +#define PROFF_SCC_SIZE ((uint)0x100) +#define PROFF_FCC_SIZE ((uint)0x100) +#define PROFF_SMC_SIZE ((uint)64) +/* The SMCs are relocated to any of the first eight DPRAM pages. * We will fix these at the first locations of DPRAM, until we * get some microcode patches :-).
include/asm-ppc/fs_pd.h +4 -0
@@ -29,4 +29,8 @@ static inline int uart_clock(void) return (((bd_t *) __res)->bi_intfreq); } +#define cpm2_map (member) (&cpm2_immr->member) +#define cpm2_map_size (member, size) (&cpm2_immr->member) +#define cpm2_unmap (addr) do {} while(0) +#endif
PATCH 6/7 POWERPC: overhaul with cpm2_map mechanism
In reply to Vitaly BordugIncorporating the new way of cpm2 immr access, introduced in the previous patch, into CPM2 peripheral devices (fs_enet and cpm_uart). Both ppc and powerpc approved working( real actions taken in powerpc only, ppc just has a wrapper to keep init stuff consistent).
---
arch/powerpc/platforms/85xx/mpc85xx_ads.c | 109 ++++++++++++++++------------- arch/powerpc/sysdev/cpm2_common.c | 90 ++++++++++++++++++++++++ arch/powerpc/sysdev/fsl_soc.c | 7 ++ arch/ppc/platforms/mpc8272ads_setup.c | 8 +- arch/ppc/platforms/mpc866ads_setup.c | 8 +- arch/ppc/platforms/mpc885ads_setup.c | 10 +-- drivers/net/fs_enet/fs_enet-main.c | 2 - drivers/serial/cpm_uart/cpm_uart_core.c | 4 + include/asm-ppc/cpm2.h | 53 ++++++++++++++ include/linux/fs_enet_pd.h | 10 ++- include/linux/fs_uart_pd.h | 4 + 11 files changed, 235 insertions(+), 70 deletions(-)
arch/powerpc/platforms/85xx/mpc85xx_ads.c +60 -49
@@ -33,6 +33,7 @@ #include <sysdev/fsl_soc.h>#include "mpc85xx.h" #ifdef CONFIG_CPM2 +#include <linux/fs_enet_pd.h> #include <asm/cpm2.h> #include <sysdev/cpm2_pic.h> #include <asm/fs_pd.h>
@@ -146,70 +147,81 @@ #endif* Setup the architecture */ #ifdef CONFIG_CPM2 -static void init_fcc_ioports (void ) +void init_fcc_ioports (struct fs_platform_info *fpi) { -struct immap *immap; -struct io_port *io; +struct io_port *io =cpm2_map (im_ioport); +int fcc_no =fs_get_fcc_index (fpi->fs_no); +int target;u32 tempval; - immap = cpm2_immr; - - io = &immap->im_ioport; -/* FCC2/3 are on the ports B/C. */ - tempval =in_be32 (&io->iop_pdirb); - tempval &= ~PB2_DIRB0 ; - tempval |=PB2_DIRB1 ; -out_be32 (&io->iop_pdirb, tempval); - - tempval =in_be32 (&io->iop_psorb); - tempval &= ~PB2_PSORB0 ; - tempval |=PB2_PSORB1 ; -out_be32 (&io->iop_psorb, tempval); - - tempval =in_be32 (&io->iop_pparb); - tempval |= (PB2_DIRB0 |PB2_DIRB1 ); -out_be32 (&io->iop_pparb, tempval); - - tempval =in_be32 (&io->iop_pdirb); - tempval &= ~PB3_DIRB0 ; - tempval |=PB3_DIRB1 ; -out_be32 (&io->iop_pdirb, tempval); - - tempval =in_be32 (&io->iop_psorb); - tempval &= ~PB3_PSORB0 ; - tempval |=PB3_PSORB1 ; -out_be32 (&io->iop_psorb, tempval); - - tempval =in_be32 (&io->iop_pparb); - tempval |= (PB3_DIRB0 |PB3_DIRB1 ); -out_be32 (&io->iop_pparb, tempval); - - tempval =in_be32 (&io->iop_pdirc); - tempval |=PC3_DIRC1 ; -out_be32 (&io->iop_pdirc, tempval); - - tempval =in_be32 (&io->iop_pparc); - tempval |=PC3_DIRC1 ; -out_be32 (&io->iop_pparc, tempval); +switch (fcc_no) { +case 1 : + tempval =in_be32 (&io->iop_pdirb); + tempval &= ~PB2_DIRB0 ; + tempval |=PB2_DIRB1 ; +out_be32 (&io->iop_pdirb, tempval); + + tempval =in_be32 (&io->iop_psorb); + tempval &= ~PB2_PSORB0 ; + tempval |=PB2_PSORB1 ; +out_be32 (&io->iop_psorb, tempval); + + tempval =in_be32 (&io->iop_pparb); + tempval |= (PB2_DIRB0 |PB2_DIRB1 ); +out_be32 (&io->iop_pparb, tempval); + + target =CPM_CLK_FCC2 ; +break ; +case 2 : + tempval =in_be32 (&io->iop_pdirb); + tempval &= ~PB3_DIRB0 ; + tempval |=PB3_DIRB1 ; +out_be32 (&io->iop_pdirb, tempval); + + tempval =in_be32 (&io->iop_psorb); + tempval &= ~PB3_PSORB0 ; + tempval |=PB3_PSORB1 ; +out_be32 (&io->iop_psorb, tempval); + + tempval =in_be32 (&io->iop_pparb); + tempval |= (PB3_DIRB0 |PB3_DIRB1 ); +out_be32 (&io->iop_pparb, tempval); + + tempval =in_be32 (&io->iop_pdirc); + tempval |=PC3_DIRC1 ; +out_be32 (&io->iop_pdirc, tempval); + + tempval =in_be32 (&io->iop_pparc); + tempval |=PC3_DIRC1 ; +out_be32 (&io->iop_pparc, tempval); + + target =CPM_CLK_FCC3 ; +break ; +default : +printk (KERN_ERR "init_fcc_ioports: invalid FCC number\n" ); +return ; + }/* Port C has clocks...... */ tempval =in_be32 (&io->iop_psorc); - tempval &= ~(CLK_TRX ); + tempval &= ~(PC_CLK (fpi->clk_rx -8 ) |PC_CLK (fpi->clk_tx -8 ));out_be32 (&io->iop_psorc, tempval); tempval =in_be32 (&io->iop_pdirc); - tempval &= ~(CLK_TRX ); + tempval &= ~(PC_CLK (fpi->clk_rx -8 ) |PC_CLK (fpi->clk_tx -8 ));out_be32 (&io->iop_pdirc, tempval); tempval =in_be32 (&io->iop_pparc); - tempval |= (CLK_TRX ); + tempval |= (PC_CLK (fpi->clk_rx -8 ) |PC_CLK (fpi->clk_tx -8 ));out_be32 (&io->iop_pparc, tempval); +cpm2_unmap (io); +/* Configure Serial Interface clock routing. -* First, clear all FCC bits to zero, +* First, clear FCC bits to zero, * then set the ones we want. */ - immap->im_cpmux.cmx_fcr &= ~(CPMUX_CLK_MASK ); - immap->im_cpmux.cmx_fcr |=CPMUX_CLK_ROUTE ; +cpm2_clk_setup (target, fpi->clk_rx,CPM_CLK_RX ); +cpm2_clk_setup (target, fpi->clk_tx,CPM_CLK_TX ); }#endif
@@ -237,7 +249,6 @@ #endif#ifdef CONFIG_CPM2 cpm2_reset (); -init_fcc_ioports ();#endif #ifdef CONFIG_PCI
arch/powerpc/sysdev/cpm2_common.c +90 -0
96 lines not on this page · raw message
arch/powerpc/sysdev/fsl_soc.c +7 -0
@@ -38,6 +38,7 @@ #ifdef CONFIG_CPM2#include <asm/cpm2.h> #endif +extern void init_fcc_ioports (struct fs_platform_info *);static phys_addr_t immrbase =-1 ;phys_addr_t get_immrbase (void )
@@ -630,6 +631,9 @@ static int __init fs_enet_of_init(void) goto unreg; } + fs_enet_data.clk_rx = *((u32 *)get_property (np,"rx-clock" ,NULL )); + fs_enet_data.clk_tx = *((u32 *)get_property (np,"tx-clock" ,NULL )); +if (strstr (model,"FCC" )) {int fcc_index =fs_get_fcc_index (*id);
@@ -646,6 +650,7 @@ static int __init fs_enet_of_init(void)snprintf ((char *)&bus_id[(*id)],BUS_ID_SIZE ,"%x:%02x" , (u32 )res.start, fs_enet_data.phy_addr); fs_enet_data.bus_id = (char *)&bus_id[(*id)]; + fs_enet_data.init_ioports = init_fcc_ioports; }of_node_put (phy);
@@ -717,6 +722,8 @@ static int __init cpm_uart_of_init(void) cpm_uart_data.tx_buf_size =32 ; cpm_uart_data.rx_num_fifo =4 ; cpm_uart_data.rx_buf_size =32 ; + cpm_uart_data.clk_rx = *((u32 *)get_property (np,"rx-clock" ,NULL )); + cpm_uart_data.clk_tx = *((u32 *)get_property (np,"tx-clock" ,NULL )); ret = platform_device_add_data(cpm_uart_dev, &cpm_uart_data,
arch/ppc/platforms/mpc8272ads_setup.c +4 -4
@@ -103,7 +103,7 @@ static struct fs_platform_info mpc82xx_e }, }; -static void init_fcc1_ioports (void ) +static void init_fcc1_ioports (struct fs_platform_info *) {struct io_port *io;u32 tempval;
@@ -144,7 +144,7 @@ static void init_fcc1_ioports(void)iounmap (immap); } -static void init_fcc2_ioports (void ) +static void init_fcc2_ioports (struct fs_platform_info *) {cpm2_map_t * immap =ioremap (CPM_MAP_ADDR ,sizeof (cpm2_map_t));u32 *bcsr =ioremap (BCSR_ADDR +12 ,sizeof (u32));
@@ -229,7 +229,7 @@ static void mpc8272ads_fixup_uart_pdata( } } -static void init_scc1_uart_ioports (void ) +static void init_scc1_uart_ioports (struct fs_uart_platform_info *) {cpm2_map_t * immap =ioremap (CPM_MAP_ADDR ,sizeof (cpm2_map_t));
@@ -246,7 +246,7 @@ static void init_scc1_uart_ioports(void)iounmap (immap); } -static void init_scc4_uart_ioports (void ) +static void init_scc4_uart_ioports (struct fs_uart_platform_info *) {cpm2_map_t * immap =ioremap (CPM_MAP_ADDR ,sizeof (cpm2_map_t));
arch/ppc/platforms/mpc866ads_setup.c +4 -4
@@ -137,7 +137,7 @@ #endifiounmap (bcsr_io); } -static void setup_fec1_ioports (void ) +static void setup_fec1_ioports (struct fs_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;
@@ -145,7 +145,7 @@ static void setup_fec1_ioports(void)setbits16 (&immap->im_ioport.iop_pddir,0x1fff ); } -static void setup_scc1_ioports (void ) +static void setup_scc1_ioports (struct fs_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;unsigned *bcsr_io;
@@ -194,7 +194,7 @@ static void setup_scc1_ioports(void) } -static void setup_smc1_ioports (void ) +static void setup_smc1_ioports (struct fs_uart_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;unsigned *bcsr_io;
@@ -216,7 +216,7 @@ static void setup_smc1_ioports(void) } -static void setup_smc2_ioports (void ) +static void setup_smc2_ioports (struct fs_uart_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;unsigned *bcsr_io;
arch/ppc/platforms/mpc885ads_setup.c +5 -5
@@ -161,7 +161,7 @@ #endif#endif } -static void setup_fec1_ioports (void ) +static void setup_fec1_ioports (struct fs_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;
@@ -181,7 +181,7 @@ static void setup_fec1_ioports(void)clrbits32 (&immap->im_cpm.cp_cptr,0x00000100 ); } -static void setup_fec2_ioports (void ) +static void setup_fec2_ioports (struct fs_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;
@@ -193,7 +193,7 @@ static void setup_fec2_ioports(void)clrbits32 (&immap->im_cpm.cp_cptr,0x00000080 ); } -static void setup_scc3_ioports (void ) +static void setup_scc3_ioports (struct fs_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;unsigned *bcsr_io;
@@ -315,7 +315,7 @@ static void __init mpc885ads_fixup_scc_empc885ads_fixup_enet_pdata (pdev, fsid_scc1 + pdev->id -1 ); } -static void setup_smc1_ioports (void ) +static void setup_smc1_ioports (struct fs_uart_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;unsigned *bcsr_io;
@@ -335,7 +335,7 @@ static void setup_smc1_ioports(void)clrbits16 (&immap->im_cpm.cp_pbodr, iobits); } -static void setup_smc2_ioports (void ) +static void setup_smc2_ioports (struct fs_uart_platform_info *) {immap_t *immap = (immap_t *)IMAP_ADDR ;unsigned *bcsr_io;
drivers/net/fs_enet/fs_enet-main.c +1 -1
@@ -971,7 +971,7 @@ static struct net_device *fs_init_instandev_set_drvdata (dev, ndev); fep->fpi = fpi;if (fpi->init_ioports) - fpi->init_ioports (); + fpi->init_ioports ((struct fs_platform_info *)fpi);#ifdef CONFIG_FS_ENET_HAS_FEC if (fs_get_fec_index (fpi->fs_no) >=0 )
drivers/serial/cpm_uart/cpm_uart_core.c +2 -2
@@ -1180,7 +1180,7 @@ static int __init cpm_uart_console_setup pdata = pdev->dev.platform_data;if (pdata)if (pdata->init_ioports) - pdata->init_ioports (); + pdata->init_ioports (pdata);cpm_uart_drv_get_platform_data (pdev,1 ); }
@@ -1269,7 +1269,7 @@ static int cpm_uart_drv_probe(struct devreturn ret;if (pdata->init_ioports) - pdata->init_ioports (); + pdata->init_ioports (pdata); ret =uart_add_one_port (&cpm_reg, &cpm_uart_ports[pdata->fs_no].port);
include/asm-ppc/cpm2.h +53 -0
58 lines not on this page · raw message
include/linux/fs_enet_pd.h +6 -4
@@ -87,18 +87,20 @@ struct fs_mii_bb_platform_info { };struct fs_platform_info { - -void (*init_ioports)(void ); + +void (*init_ioports)(struct fs_platform_info *);/* device specific information */ int fs_no;/* controller index */ u32 cp_page;/* CPM page */ u32 cp_block;/* CPM sblock */ - +u32 clk_trx;/* some stuff for pins & mux configuration*/ +u32 clk_rx; +u32 clk_tx;u32 clk_route;u32 clk_mask; - +u32 mem_offset;u32 dpram_offset;u32 fcc_regs_c;
include/linux/fs_uart_pd.h +3 -1
@@ -46,7 +46,7 @@ static inline int fs_uart_id_fsid2smc(in }struct fs_uart_platform_info { -void (*init_ioports)(void ); +void (*init_ioports)(struct fs_uart_platform_info *);/* device specific information */ int fs_no;/* controller index */ u32 uart_clk;
@@ -55,6 +55,8 @@ struct fs_uart_platform_info {u8 rx_num_fifo;u8 rx_buf_size;u8 brg; +u8 clk_rx; + u8 clk_tx; };#endif
PATCH 7/7 POWERPC: Bring the fs_no calculation to the relevant SoC enumeration
In reply to Vitaly BordugThe fs_no mean used to be fs_enet driver driven, hence it was an enumeration across all the possible fs_enet "users" in the SoC. Now, with QE on the pipeline, and to make DTS descriptions more clear, fs_no features relevant SoC part number, with additional field to describe the SoC type.
Another reason for that is now not only fs_enet is going to utilize those stuff. There might be UART, HLDC, and even USB, so to prevent confusion and be ready for upcoming OF_device transfer, fs_enet and cpm_uart drivers were updated in that concern, as well as the relevant DTS.
---
arch/powerpc/boot/dts/mpc8560ads.dts | 8 +++---- arch/powerpc/sysdev/fsl_soc.c | 8 ++++++- drivers/net/fs_enet/fs_enet-main.c | 3 ++- drivers/serial/cpm_uart/cpm_uart_core.c | 9 +++++--- include/linux/fs_enet_pd.h | 37 +++++++++++++++++++++++++++++++ include/linux/fs_uart_pd.h | 10 ++++++++ 6 files changed, 66 insertions(+), 9 deletions(-)
arch/powerpc/boot/dts/mpc8560ads.dts +4 -4
@@ -244,7 +244,7 @@ device_type = "serial"; compatible = "cpm_uart"; model = "SCC"; - device-id = <2>; + device-id = <1>; reg = <91a00 20 88000 100>; clock-setup = <00ffffff 0>; rx-clock = <1>;
@@ -258,7 +258,7 @@ device_type = "serial"; compatible = "cpm_uart"; model = "SCC"; - device-id = <3>; + device-id = <2>; reg = <91a20 20 88100 100>; clock-setup = <ff00ffff 90000>; rx-clock = <2>;
@@ -272,7 +272,7 @@ device_type = "network"; compatible = "fs_enet"; model = "FCC"; - device-id = <3>; + device-id = <2>; reg = <91320 20 88500 100 913a0 30>; mac-address = [ 00 00 0C 00 02 FD ]; clock-setup = <ff00ffff 250000>;
@@ -287,7 +287,7 @@ device_type = "network"; compatible = "fs_enet"; model = "FCC"; - device-id = <4>; + device-id = <3>; reg = <91340 20 88600 100 913d0 30>; mac-address = [ 00 00 0C 00 03 FD ]; clock-setup = <ffff00ff 3700>;
arch/powerpc/sysdev/fsl_soc.c +7 -1
@@ -622,6 +622,7 @@ static int __init fs_enet_of_init(void) id = (u32 *)get_property (np,"device-id" ,NULL ); fs_enet_data.fs_no = *id; +strcpy (fs_enet_data.fs_type, model); mdio =of_get_parent (phy); ret =of_address_to_resource (mdio,0 , &res);
@@ -635,7 +636,7 @@ static int __init fs_enet_of_init(void) fs_enet_data.clk_tx = *((u32 *)get_property (np,"tx-clock" ,NULL ));if (strstr (model,"FCC" )) { -int fcc_index =fs_get_fcc_index (*id); +int fcc_index = *id -1 ; fs_enet_data.dpram_offset = (u32 )cpm_dpram_addr (0 ); fs_enet_data.rx_ring =32 ;
@@ -688,6 +689,7 @@ static int __init cpm_uart_of_init(void)struct resource r[3 ];struct fs_uart_platform_info cpm_uart_data;int *id; +char *model;memset (r,0 ,sizeof (r));memset (&cpm_uart_data,0 ,sizeof (cpm_uart_data));
@@ -716,6 +718,10 @@ static int __init cpm_uart_of_init(void) id = (int *)get_property (np,"device-id" ,NULL ); cpm_uart_data.fs_no = *id; + + model = (char *)get_property (np,"model" ,NULL ); +strcpy (cpm_uart_data.fs_type, model); + cpm_uart_data.uart_clk = ppc_proc_freq; cpm_uart_data.tx_num_fifo =4 ;
drivers/net/fs_enet/fs_enet-main.c +2 -1
@@ -944,12 +944,13 @@ extern int fs_mii_connect(struct net_devextern void fs_mii_disconnect (struct net_device *dev);static struct net_device *fs_init_instance (struct device *dev, -const struct fs_platform_info *fpi) +struct fs_platform_info *fpi) {struct net_device *ndev =NULL ;struct fs_enet_private *fep =NULL ;int privsize, i, r, err =0 , registered =0 ; + fpi->fs_no =fs_get_id (fpi);/* guard */ if ((unsigned int )fpi->fs_no >=FS_MAX_INDEX )return ERR_PTR (-EINVAL );
drivers/serial/cpm_uart/cpm_uart_core.c +6 -3
@@ -1023,15 +1023,17 @@ int cpm_uart_drv_get_platform_data(struc {struct resource *r;struct fs_uart_platform_info *pdata = pdev->dev.platform_data; -int idx = pdata->fs_no;/* It is UART_SMCx or UART_SCCx index */ +int idx;/* It is UART_SMCx or UART_SCCx index */ struct uart_cpm_port *pinfo;int line;u32 mem, pram; + idx = pdata->fs_no =fs_uart_get_id (pdata); + line =cpm_uart_id2nr (idx);if (line <0 ) {printk (KERN_ERR "%s(): port %d is not registered" , __FUNCTION__, idx); -return -1 ; +return -EINVAL ; } pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx];
@@ -1263,11 +1265,12 @@ static int cpm_uart_drv_probe(struct dev } pdata = pdev->dev.platform_data; -pr_debug ("cpm_uart_drv_probe: Adding CPM UART %d\n" ,cpm_uart_id2nr (pdata->fs_no));if ((ret =cpm_uart_drv_get_platform_data (pdev,0 )))return ret; +pr_debug ("cpm_uart_drv_probe: Adding CPM UART %d\n" ,cpm_uart_id2nr (pdata->fs_no)); +if (pdata->init_ioports) pdata->init_ioports (pdata);
include/linux/fs_enet_pd.h +37 -0
@@ -55,6 +55,30 @@ static inline int fs_get_scc_index(enumreturn -1 ; } +static inline int fs_fec_index2id (int index) +{ +int id = fsid_fec1 + index -1 ; +if (id >= fsid_fec1 && id <= fsid_fec2) +return id; +return FS_MAX_INDEX ; + } + +static inline int fs_fcc_index2id (int index) +{ +int id = fsid_fcc1 + index -1 ; +if (id >= fsid_fcc1 && id <= fsid_fcc3) +return id; +return FS_MAX_INDEX ; +} + +static inline int fs_scc_index2id (int index) +{ +int id = fsid_scc1 + index -1 ; +if (id >= fsid_scc1 && id <= fsid_scc4) +return id; +return FS_MAX_INDEX ; +} +enum fs_mii_method { fsmii_fixed, fsmii_fec,
@@ -91,6 +115,7 @@ struct fs_platform_info {void (*init_ioports)(struct fs_platform_info *);/* device specific information */ int fs_no;/* controller index */ +char fs_type[4 ];/* controller type */ u32 cp_page;/* CPM page */ u32 cp_block;/* CPM sblock */
@@ -126,4 +151,16 @@ struct fs_mii_fec_platform_info {u32 irq[32 ]; u32 mii_speed; }; + +static inline int fs_get_id (struct fs_platform_info *fpi) +{ +if (strstr (fpi->fs_type,"SCC" )) +return fs_scc_index2id (fpi->fs_no); +if (strstr (fpi->fs_type,"FCC" )) +return fs_fcc_index2id (fpi->fs_no); +if (strstr (fpi->fs_type,"FEC" )) +return fs_fec_index2id (fpi->fs_no); +return fpi->fs_no; +} +#endif
include/linux/fs_uart_pd.h +10 -0
@@ -49,6 +49,7 @@ struct fs_uart_platform_info {void (*init_ioports)(struct fs_uart_platform_info *);/* device specific information */ int fs_no;/* controller index */ +char fs_type[4 ];/* controller type */ u32 uart_clk;u8 tx_num_fifo;u8 tx_buf_size;
@@ -59,4 +60,13 @@ struct fs_uart_platform_info { u8 clk_tx; }; +static inline int fs_uart_get_id (struct fs_uart_platform_info *fpi) +{ +if (strstr (fpi->fs_type,"SMC" )) +return fs_uart_id_smc2fsid (fpi->fs_no); +if (strstr (fpi->fs_type,"SCC" )) +return fs_uart_id_scc2fsid (fpi->fs_no); +return fpi->fs_no; +} +#endif
Re: [PATCH 1/7] POWERPC: Add cpm2 stuff support to the fsl_soc.c
In reply to Vitaly BordugHi Vitaly,
Just a few nits ...
arch/powerpc/sysdev/fsl_soc.c #include <linux/module.h> · line 39
Quoted 4 lines · On Fri, 15 Sep 2006 21:38:57 +0400 Vitaly Bordug <[email protected]> wrote:
arch/powerpc/sysdev/fsl_soc.c +3
-0+#ifdef CONFIG_CPM2 +#include <asm/cpm2.h> +#endif
We normally don't do conditional includes, the include file should protect its contents (if that is necessary - it usually isn't).
arch/powerpc/sysdev/fsl_soc.c phys_addr_t get_immrbase(void) · line 79
Quoted 1 line
arch/powerpc/sysdev/fsl_soc.c +1
-0+unsigned int *prop = (unsigned int *)get_property (node,"brg-frequency" , &size);
get_property returns "const void *" so no cast is necessary, but prop should be declated "const unsigned int *".
arch/powerpc/sysdev/fsl_soc.c phys_addr_t get_immrbase(void) · line 103
Quoted 1 line
arch/powerpc/sysdev/fsl_soc.c +1
-0+unsigned int *prop = (unsigned int *)get_property (node,"current-speed" , &size);
Ditto.
arch/powerpc/sysdev/fsl_soc.c err: · line 551
Quoted 3 lines
arch/powerpc/sysdev/fsl_soc.c +3
-0+static const char *fcc_regs ="fcc_regs" ; +static const char *fcc_regs_c ="fcc_regs_c" ; +static const char *fcc_pram ="fcc_pram" ;
I think that these could be declared as const char [].
arch/powerpc/sysdev/fsl_soc.c err: · line 622
Quoted 5 lines
arch/powerpc/sysdev/fsl_soc.c +5
-0+ model = (char *)get_property (np,"model" ,NULL ); + mac_addr = (void *)get_property (np,"mac-address" ,NULL ); + ph = (phandle *)get_property (np,"phy-handle" ,NULL ); + phy_addr = (u32 *)get_property (phy,"reg" ,NULL ); + id = (u32 *)get_property (np,"device-id" ,NULL );
Same comments about const and void * with respect to get_property. There are more ...
arch/powerpc/sysdev/fsl_soc.c err: · line 671
Quoted 2 lines
arch/powerpc/sysdev/fsl_soc.c +2
-0+static const char *scc_regs ="regs" ; +static const char *scc_pram ="pram" ;
const char [] ?
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Re: [PATCH 3/7] POWERPC: Move generic cpm2 stuff to powerpc
In reply to Vitaly BordugHi Vitaly,
Seems I am in nit picking mood tonight ..
Review
Quoted 3 lines · On Fri, 15 Sep 2006 21:39:12 +0400 Vitaly Bordug <[email protected]> wrote:
(quoted diff) +2
-0+# Temporary hack until we have migrated to asm-powerpc +ifeq ($(ARCH),powerpc)
I think we normally use:
ifeq ($(CONFIG_PPC_MERGE),y)
arch/powerpc/sysdev/cpm2_common.c line 92
Quoted 4 lines
arch/powerpc/sysdev/cpm2_common.c new file +4
-0+if (brg <4 ) { + bp = (uint *)&cpm2_immr->im_brgc1; + } +else {
Normally:
if (brg < 4)
bp = (uint *)&cpm2_immr->im_brgc1;
else {Quoted 1 line
+static
u_charirq_to_siureg[] = {
const ?
Quoted 1 line
+static
u_charirq_to_siubit[] = {
ditto
Quoted 4 lines
arch/powerpc/sysdev/cpm2_pic.c new file +4
-0+int cpm2_get_irq (struct pt_regs *regs) +{ +int irq; +unsigned long bits;
arch/powerpc/sysdev/cpm2_pic.c line 161
Quoted 10 lines
arch/powerpc/sysdev/cpm2_pic.c new file +10
-0+ +/* For CPM2, read the SIVEC register and shift the bits down +* to get the irq number. */ + bits = cpm2_immr->im_intctl.ic_sivec; + irq = bits >>26 ; + +if (irq ==0 ) +return (-1 ); +return irq+CPM_IRQ_OFFSET ; +}
Indentation needs fixing - we use single tab characters to indent.
arch/powerpc/sysdev/cpm2_pic.c line 191
Quoted 5 lines
arch/powerpc/sysdev/cpm2_pic.c new file +5
-0+static int cpm2_pic_host_xlate (struct irq_host *h,struct device_node *ct, +u32 *intspec,unsigned int intsize, +irq_hw_number_t *out_hwirq,unsigned int *out_flags) +{ +static unsigned char map_cpm2_senses[4 ] = {
const ?
Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/
Re: [PATCH 3/7] POWERPC: Move generic cpm2 stuff to powerpc
Quoted 10 lines · Stephen Rothwell
arch/powerpc/sysdev/cpm2_common.c line 92
Quoted 5 lines
arch/powerpc/sysdev/cpm2_common.c new file +4
-0+if (brg <4 ) { + bp = (uint *)&cpm2_immr->im_brgc1; + } +else {Normally:
if (brg < 4) bp = (uint *)&cpm2_immr->im_brgc1; else {
Sorry, I'm going to nit-pick right back. This isn't "normal", it's just your preference. :-)
When the "else" part contains braces, the "if" part should as well. If this get modified and nested some day in the future, this can cause a very subtle coding error.
No one should ever be criticized for using too many braces, provided it is artistically pleasing.
"Normally," the if-else without braces is only used when there are single statements on both paths of the logic. The only exception is the else-if that emulates a case statement (when other exceptions also apply, see K&R).
Thanks.
-- Dan
Re: [PATCH 3/7] POWERPC: Move generic cpm2 stuff to powerpc
Quoted 13 lines · Dan Malek
Quoted 10 lines · Stephen Rothwell
arch/powerpc/sysdev/cpm2_common.c line 92
Quoted 5 lines
arch/powerpc/sysdev/cpm2_common.c new file +4
-0+if (brg <4 ) { + bp = (uint *)&cpm2_immr->im_brgc1; + } +else {Normally:
if (brg < 4) bp = (uint *)&cpm2_immr->im_brgc1; else {
Quoted 2 lines
Sorry, I'm going to nit-pick right back. This isn't "normal", it's just your preference. :-)
Nothing is "normal" in C coding style, it's all a matter of preference. Not having braces around a single-line statement is indeed a preference shared by the majority of the kernel maintainers, and thus becomes de-facto the rule, which we can then qualify as "normal" in the context of the linux kernel :)
Quoted 22 lines
When the "else" part contains braces, the "if" part should as well. If this get modified and nested some day in the future, this can cause a very subtle coding error.
No one should ever be criticized for using too many braces, provided it is artistically pleasing.
"Normally," the if-else without braces is only used when there are single statements on both paths of the logic. The only exception is the else-if that emulates a case statement (when other exceptions also apply, see K&R).
Thanks.
-- Dan_______________________________________________
Linuxppc-dev mailing list
[email protected]
https://ozlabs.org/mailman/listinfo/linuxppc-dev
Re: [PATCH 3/7] POWERPC: Move generic cpm2 stuff to powerpc
In reply to Dan MalekQuoted 15 lines · On Sat, 16 Sep 2006 12:09:34 -0400 Dan Malek <[email protected]> wrote:
Quoted 10 lines · Stephen Rothwell
arch/powerpc/sysdev/cpm2_common.c line 92
Quoted 5 lines
arch/powerpc/sysdev/cpm2_common.c new file +4
-0+if (brg <4 ) { + bp = (uint *)&cpm2_immr->im_brgc1; + } +else {Normally:
if (brg < 4) bp = (uint *)&cpm2_immr->im_brgc1; else {
Quoted 7 lines
Sorry, I'm going to nit-pick right back. This isn't "normal", it's just your preference. :-)
When the "else" part contains braces, the "if" part should as well. If this get modified and nested some day in the future, this can cause a very subtle coding error.
Not if you are consistent (and many aren't, I agree).
I was more commenting on the
}
else {bit wich should (at worst) be
} else {Signature · 3 lines
Cheers, Stephen Rothwell [email protected] http://www.canb.auug.org.au/~sfr/