From: Anton Vorontsov <avorontsov@ru.mvista.com>
To: linuxppc-dev@ozlabs.org
Subject: [PATCH v6 1/2] [POWERPC] fsl_soc: add support for fsl_spi
Date: Wed, 22 Aug 2007 18:57:32 +0400 [thread overview]
Message-ID: <20070822145732.GA22686@localhost.localdomain> (raw)
In-Reply-To: <20070822145415.GA22595@localhost.localdomain>
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
---
arch/powerpc/sysdev/fsl_soc.c | 81 +++++++++++++++++++++++++++++++++++++++++
arch/powerpc/sysdev/fsl_soc.h | 7 ++++
2 files changed, 88 insertions(+), 0 deletions(-)
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c
index 1cf29c9..473b45b 100644
--- a/arch/powerpc/sysdev/fsl_soc.c
+++ b/arch/powerpc/sysdev/fsl_soc.c
@@ -24,6 +24,7 @@
#include <linux/platform_device.h>
#include <linux/of_platform.h>
#include <linux/phy.h>
+#include <linux/spi/spi.h>
#include <linux/fsl_devices.h>
#include <linux/fs_enet_pd.h>
#include <linux/fs_uart_pd.h>
@@ -1187,3 +1188,83 @@ 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;
+ 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;
+
+ ret = of_irq_to_resource(np, 0, &res[1]);
+ if (ret == NO_IRQ)
+ goto err;
+
+ 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
next prev parent reply other threads:[~2007-08-22 14:57 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-21 13:45 [PATCH v4 0/2] SPI support for fsl_soc and mpc832x_rdb Anton Vorontsov
2007-08-21 13:47 ` [PATCH v4 1/2] [POWERPC] fsl_soc: add support for fsl_spi Anton Vorontsov
2007-08-21 13:47 ` [PATCH v4 2/2] [POWERPC] MPC832x_RDB: update dts to use SPI1 in QE, register mmc_spi stub Anton Vorontsov
2007-08-21 15:27 ` [PATCH v5 0/2] SPI support for fsl_soc and mpc832x_rdb Anton Vorontsov
2007-08-21 15:29 ` [PATCH v5 1/2] [POWERPC] fsl_soc: add support for fsl_spi Anton Vorontsov
2007-08-22 14:24 ` Kumar Gala
2007-08-21 15:29 ` [PATCH v5 2/2] [POWERPC] MPC832x_RDB: update dts to use SPI1 in QE, register mmc_spi stub Anton Vorontsov
2007-08-22 14:25 ` Kumar Gala
2007-08-22 14:22 ` [PATCH v5 0/2] SPI support for fsl_soc and mpc832x_rdb Kumar Gala
2007-08-22 14:54 ` [PATCH v6 " Anton Vorontsov
2007-08-22 14:57 ` Anton Vorontsov [this message]
2007-08-23 3:24 ` [PATCH v6 1/2] [POWERPC] fsl_soc: add support for fsl_spi Stephen Rothwell
2007-08-23 11:33 ` [PATCH v7 0/3] " Anton Vorontsov
2007-08-23 11:35 ` [PATCH v7 1/3] [POWERPC] QE lib: extern par_io_config_pin and par_io_data_set funcs Anton Vorontsov
2007-08-23 11:35 ` [PATCH v7 2/3] [POWERPC] fsl_soc: add support for fsl_spi Anton Vorontsov
2007-08-23 11:36 ` [PATCH v7 3/3] [POWERPC] MPC832x_RDB: update dts to use SPI1 in QE, register mmc_spi stub Anton Vorontsov
2007-08-30 21:06 ` Timur Tabi
2007-08-31 13:50 ` [PATCH v7 3/3] [POWERPC] MPC832x_RDB: update dts to use SPI1in " Li Yang-r58472
2007-09-01 23:59 ` Segher Boessenkool
2007-09-03 13:55 ` Timur Tabi
2007-09-03 15:13 ` Anton Vorontsov
2007-09-03 23:17 ` Segher Boessenkool
2007-09-04 10:47 ` Anton Vorontsov
2007-09-04 18:20 ` Scott Wood
2007-09-04 20:15 ` Vitaly Bordug
2007-09-05 11:40 ` Anton Vorontsov
2007-09-05 13:21 ` Scott Wood
2007-09-07 1:15 ` David Gibson
2007-09-07 1:28 ` Timur Tabi
2007-09-06 14:25 ` Segher Boessenkool
2007-09-06 14:19 ` Segher Boessenkool
2007-09-06 14:35 ` Timur Tabi
2007-09-03 23:12 ` Segher Boessenkool
2007-09-04 3:16 ` Timur Tabi
2007-09-06 14:13 ` Segher Boessenkool
2007-09-06 14:19 ` Scott Wood
2007-09-06 14:29 ` Segher Boessenkool
2007-09-07 3:37 ` David Gibson
2007-08-22 14:57 ` [PATCH v6 2/2] [POWERPC] MPC832x_RDB: update dts to use SPI1 in " Anton Vorontsov
2007-08-22 15:01 ` [PATCH v6 0/2] SPI support for fsl_soc and mpc832x_rdb Kumar Gala
2007-08-22 15:13 ` Anton Vorontsov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070822145732.GA22686@localhost.localdomain \
--to=avorontsov@ru.mvista.com \
--cc=linuxppc-dev@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).