diff options
author | Anton Vorontsov <avorontsov@ru.mvista.com> | 2009-03-31 18:24:36 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-04-01 11:59:22 -0400 |
commit | 364fdbc00fbdd409ade63500710123fe323aa164 (patch) | |
tree | 0a2c4c85f5dd3b6e91ff5d68f419069178e5a9bb /arch/powerpc | |
parent | 34c8a20c6ee6af25ee35da9ca15ba81faacfc73d (diff) |
spi_mpc83xx: rework chip selects handling
The main purpose of this patch is to pass 'struct spi_device' to the chip
select handling routines. This is needed so that we could implement
full-fledged OpenFirmware support for this driver.
While at it, also:
- Replace two {de,activate}_cs routines by single cs_contol().
- Don't duplicate platform data callbacks in mpc83xx_spi struct.
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: David Brownell <david-b@pacbell.net>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Kumar Gala <galak@gate.crashing.org>
Cc: Grant Likely <grant.likely@secretlab.ca>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/platforms/83xx/mpc832x_rdb.c | 16 | ||||
-rw-r--r-- | arch/powerpc/sysdev/fsl_soc.c | 14 | ||||
-rw-r--r-- | arch/powerpc/sysdev/fsl_soc.h | 5 |
3 files changed, 13 insertions, 22 deletions
diff --git a/arch/powerpc/platforms/83xx/mpc832x_rdb.c b/arch/powerpc/platforms/83xx/mpc832x_rdb.c index 2a1295f19832..28e23cde64a1 100644 --- a/arch/powerpc/platforms/83xx/mpc832x_rdb.c +++ b/arch/powerpc/platforms/83xx/mpc832x_rdb.c | |||
@@ -39,16 +39,10 @@ | |||
39 | #endif | 39 | #endif |
40 | 40 | ||
41 | #ifdef CONFIG_QUICC_ENGINE | 41 | #ifdef CONFIG_QUICC_ENGINE |
42 | static void mpc83xx_spi_activate_cs(u8 cs, u8 polarity) | 42 | static void mpc83xx_spi_cs_control(struct spi_device *spi, bool on) |
43 | { | 43 | { |
44 | pr_debug("%s %d %d\n", __func__, cs, polarity); | 44 | pr_debug("%s %d %d\n", __func__, spi->chip_select, on); |
45 | par_io_data_set(3, 13, polarity); | 45 | par_io_data_set(3, 13, on); |
46 | } | ||
47 | |||
48 | static void mpc83xx_spi_deactivate_cs(u8 cs, u8 polarity) | ||
49 | { | ||
50 | pr_debug("%s %d %d\n", __func__, cs, polarity); | ||
51 | par_io_data_set(3, 13, !polarity); | ||
52 | } | 46 | } |
53 | 47 | ||
54 | static struct mmc_spi_platform_data mpc832x_mmc_pdata = { | 48 | static struct mmc_spi_platform_data mpc832x_mmc_pdata = { |
@@ -74,9 +68,7 @@ static int __init mpc832x_spi_init(void) | |||
74 | par_io_config_pin(3, 14, 2, 0, 0, 0); /* SD_INSERT, I */ | 68 | par_io_config_pin(3, 14, 2, 0, 0, 0); /* SD_INSERT, I */ |
75 | par_io_config_pin(3, 15, 2, 0, 0, 0); /* SD_PROTECT,I */ | 69 | par_io_config_pin(3, 15, 2, 0, 0, 0); /* SD_PROTECT,I */ |
76 | 70 | ||
77 | return fsl_spi_init(&mpc832x_spi_boardinfo, 1, | 71 | return fsl_spi_init(&mpc832x_spi_boardinfo, 1, mpc83xx_spi_cs_control); |
78 | mpc83xx_spi_activate_cs, | ||
79 | mpc83xx_spi_deactivate_cs); | ||
80 | } | 72 | } |
81 | machine_device_initcall(mpc832x_rdb, mpc832x_spi_init); | 73 | machine_device_initcall(mpc832x_rdb, mpc832x_spi_init); |
82 | #endif /* CONFIG_QUICC_ENGINE */ | 74 | #endif /* CONFIG_QUICC_ENGINE */ |
diff --git a/arch/powerpc/sysdev/fsl_soc.c b/arch/powerpc/sysdev/fsl_soc.c index a01c89d3f9bd..a46c1c867930 100644 --- a/arch/powerpc/sysdev/fsl_soc.c +++ b/arch/powerpc/sysdev/fsl_soc.c | |||
@@ -420,8 +420,8 @@ arch_initcall(fsl_usb_of_init); | |||
420 | static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk, | 420 | static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk, |
421 | struct spi_board_info *board_infos, | 421 | struct spi_board_info *board_infos, |
422 | unsigned int num_board_infos, | 422 | unsigned int num_board_infos, |
423 | void (*activate_cs)(u8 cs, u8 polarity), | 423 | void (*cs_control)(struct spi_device *dev, |
424 | void (*deactivate_cs)(u8 cs, u8 polarity)) | 424 | bool on)) |
425 | { | 425 | { |
426 | struct device_node *np; | 426 | struct device_node *np; |
427 | unsigned int i = 0; | 427 | unsigned int i = 0; |
@@ -433,8 +433,7 @@ static int __init of_fsl_spi_probe(char *type, char *compatible, u32 sysclk, | |||
433 | struct resource res[2]; | 433 | struct resource res[2]; |
434 | struct platform_device *pdev; | 434 | struct platform_device *pdev; |
435 | struct fsl_spi_platform_data pdata = { | 435 | struct fsl_spi_platform_data pdata = { |
436 | .activate_cs = activate_cs, | 436 | .cs_control = cs_control, |
437 | .deactivate_cs = deactivate_cs, | ||
438 | }; | 437 | }; |
439 | 438 | ||
440 | memset(res, 0, sizeof(res)); | 439 | memset(res, 0, sizeof(res)); |
@@ -501,8 +500,7 @@ next: | |||
501 | 500 | ||
502 | int __init fsl_spi_init(struct spi_board_info *board_infos, | 501 | int __init fsl_spi_init(struct spi_board_info *board_infos, |
503 | unsigned int num_board_infos, | 502 | unsigned int num_board_infos, |
504 | void (*activate_cs)(u8 cs, u8 polarity), | 503 | void (*cs_control)(struct spi_device *spi, bool on)) |
505 | void (*deactivate_cs)(u8 cs, u8 polarity)) | ||
506 | { | 504 | { |
507 | u32 sysclk = -1; | 505 | u32 sysclk = -1; |
508 | int ret; | 506 | int ret; |
@@ -518,10 +516,10 @@ int __init fsl_spi_init(struct spi_board_info *board_infos, | |||
518 | } | 516 | } |
519 | 517 | ||
520 | ret = of_fsl_spi_probe(NULL, "fsl,spi", sysclk, board_infos, | 518 | ret = of_fsl_spi_probe(NULL, "fsl,spi", sysclk, board_infos, |
521 | num_board_infos, activate_cs, deactivate_cs); | 519 | num_board_infos, cs_control); |
522 | if (!ret) | 520 | if (!ret) |
523 | of_fsl_spi_probe("spi", "fsl_spi", sysclk, board_infos, | 521 | of_fsl_spi_probe("spi", "fsl_spi", sysclk, board_infos, |
524 | num_board_infos, activate_cs, deactivate_cs); | 522 | num_board_infos, cs_control); |
525 | 523 | ||
526 | return spi_register_board_info(board_infos, num_board_infos); | 524 | return spi_register_board_info(board_infos, num_board_infos); |
527 | } | 525 | } |
diff --git a/arch/powerpc/sysdev/fsl_soc.h b/arch/powerpc/sysdev/fsl_soc.h index 9c744e4285a0..b5f3456780b8 100644 --- a/arch/powerpc/sysdev/fsl_soc.h +++ b/arch/powerpc/sysdev/fsl_soc.h | |||
@@ -4,6 +4,8 @@ | |||
4 | 4 | ||
5 | #include <asm/mmu.h> | 5 | #include <asm/mmu.h> |
6 | 6 | ||
7 | struct spi_device; | ||
8 | |||
7 | extern phys_addr_t get_immrbase(void); | 9 | extern phys_addr_t get_immrbase(void); |
8 | #if defined(CONFIG_CPM2) || defined(CONFIG_QUICC_ENGINE) || defined(CONFIG_8xx) | 10 | #if defined(CONFIG_CPM2) || defined(CONFIG_QUICC_ENGINE) || defined(CONFIG_8xx) |
9 | extern u32 get_brgfreq(void); | 11 | extern u32 get_brgfreq(void); |
@@ -19,8 +21,7 @@ struct device_node; | |||
19 | 21 | ||
20 | extern int fsl_spi_init(struct spi_board_info *board_infos, | 22 | extern int fsl_spi_init(struct spi_board_info *board_infos, |
21 | unsigned int num_board_infos, | 23 | unsigned int num_board_infos, |
22 | void (*activate_cs)(u8 cs, u8 polarity), | 24 | void (*cs_control)(struct spi_device *spi, bool on)); |
23 | void (*deactivate_cs)(u8 cs, u8 polarity)); | ||
24 | 25 | ||
25 | extern void fsl_rstcr_restart(char *cmd); | 26 | extern void fsl_rstcr_restart(char *cmd); |
26 | 27 | ||