From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTP id 38625DDE40 for ; Thu, 23 Aug 2007 00:22:16 +1000 (EST) In-Reply-To: <20070821152942.GA633@localhost.localdomain> References: <20070821152745.GA28986@localhost.localdomain> <20070821152942.GA633@localhost.localdomain> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <74A1E294-97A9-4CC6-8AEF-62EDF0838EA5@kernel.crashing.org> From: Kumar Gala Subject: Re: [PATCH v5 1/2] [POWERPC] fsl_soc: add support for fsl_spi Date: Wed, 22 Aug 2007 09:24:17 -0500 To: Anton Vorontsov Cc: linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Aug 21, 2007, at 10:29 AM, Anton Vorontsov wrote: > Signed-off-by: Anton Vorontsov > --- > arch/powerpc/sysdev/fsl_soc.c | 84 ++++++++++++++++++++++++++++++ > +++++++++++ > arch/powerpc/sysdev/fsl_soc.h | 7 +++ > 2 files changed, 91 insertions(+), 0 deletions(-) > > diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/ > fsl_soc.c > index 1cf29c9..2bdaeb2 100644 > --- a/arch/powerpc/sysdev/fsl_soc.c > +++ b/arch/powerpc/sysdev/fsl_soc.c > @@ -24,6 +24,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -1187,3 +1188,86 @@ err: > arch_initcall(cpm_smc_uart_of_init); > > #endif /* CONFIG_8xx */ > + > +int __init fsl_spi_init(struct spi_board_info *board_infos, > + unsigned int num_board_infos, > + void (*activate_cs)(u8 cs, u8 polarity), > + void (*deactivate_cs)(u8 cs, u8 polarity)) > +{ > + struct device_node *np; > + unsigned int i; > + u32 sysclk; > + > + np = of_find_node_by_type(NULL, "qe"); > + if (!np) > + return -ENODEV; > + > + sysclk = *(u32 *)of_get_property(np, "bus-frequency", NULL); > + > + for (np = NULL, i = 1; > + (np = of_find_compatible_node(np, "spi", "fsl_spi")) != NULL; > + i++) { > + int ret = 0; > + unsigned int j; > + const char *mode; > + struct resource res[2]; > + struct platform_device *pdev = NULL; > + struct fsl_spi_platform_data pdata = { > + .activate_cs = activate_cs, > + .deactivate_cs = deactivate_cs, > + }; > + > + memset(res, 0, sizeof(res)); > + > + mode = of_get_property(np, "mode", NULL); > + pdata.sysclk = sysclk; > + pdata.bus_num = *(u32 *)of_get_property(np, "reg", NULL); > + > + for (j = 0; j < num_board_infos; j++) { > + if (board_infos[j].bus_num == pdata.bus_num) > + pdata.max_chipselect++; > + } > + > + if (!pdata.max_chipselect) > + goto err; > + > + if (!strcmp(mode, "cpu-qe")) > + pdata.qe_mode = 1; > + > + ret = of_address_to_resource(np, 0, &res[0]); > + if (ret) > + goto err; > + > + res[1].start = res[2].end = irq_of_parse_and_map(np, 0); > + if (res[1].start == NO_IRQ) > + goto err; > + > + res[1].name = "mpc83xx_spi"; > + res[1].flags = IORESOURCE_IRQ;; double ;; can we not use of_irq_to_resource() ? > + > + pdev = platform_device_alloc("mpc83xx_spi", i); > + if (!pdev) > + goto err; > + > + ret = platform_device_add_data(pdev, &pdata, sizeof(pdata)); > + if (ret) > + goto unreg; > + > + ret = platform_device_add_resources(pdev, res, > + ARRAY_SIZE(res)); > + if (ret) > + goto unreg; > + > + ret = platform_device_register(pdev); > + if (ret) > + goto unreg; > + > + continue; > +unreg: > + platform_device_del(pdev); > +err: > + continue; > + } > + > + return spi_register_board_info(board_infos, num_board_infos); > +} > diff --git a/arch/powerpc/sysdev/fsl_soc.h b/arch/powerpc/sysdev/ > fsl_soc.h > index 04e145b..618d91d 100644 > --- a/arch/powerpc/sysdev/fsl_soc.h > +++ b/arch/powerpc/sysdev/fsl_soc.h > @@ -8,5 +8,12 @@ extern phys_addr_t get_immrbase(void); > extern u32 get_brgfreq(void); > extern u32 get_baudrate(void); > > +struct spi_board_info; > + > +extern int fsl_spi_init(struct spi_board_info *board_infos, > + unsigned int num_board_infos, > + void (*activate_cs)(u8 cs, u8 polarity), > + void (*deactivate_cs)(u8 cs, u8 polarity)); > + > #endif > #endif > -- > 1.5.0.6 > > _______________________________________________ > Linuxppc-dev mailing list > Linuxppc-dev@ozlabs.org > https://ozlabs.org/mailman/listinfo/linuxppc-dev