aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-ep93xx
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@iki.fi>2010-05-11 10:34:54 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2010-05-13 07:19:52 -0400
commit4fec9978822a66b25f5645eb20c115034a18cfd1 (patch)
treefc6c064697704c5a86e2f6c7ac9ae77f60cbd80d /arch/arm/mach-ep93xx
parent99e6a23adfadc2da2006f3715c4332c3bf502c07 (diff)
ARM: 6124/1: ep93xx: SPI driver platform support code
This patch adds platform side support code for the EP93xx SPI driver. This includes clock, resources and muxing. There is a new function: ep93xx_register_spi() which can be used by board support code to register new SPI devices for the board. This patch depends on patch 5998/1 ep93xx: added chip revision reading function Cc: Ryan Mallon <ryan@bluewatersys.com> Cc: David Brownell <dbrownell@users.sourceforge.net> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Mika Westerberg <mika.westerberg@iki.fi> Acked-by: H Hartley Sweeten <hsweeten@visionengravers.com> Acked-by: Martin Guy <martinwguy@gmail.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/arm/mach-ep93xx')
-rw-r--r--arch/arm/mach-ep93xx/clock.c13
-rw-r--r--arch/arm/mach-ep93xx/core.c52
-rw-r--r--arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h1
-rw-r--r--arch/arm/mach-ep93xx/include/mach/platform.h4
4 files changed, 70 insertions, 0 deletions
diff --git a/arch/arm/mach-ep93xx/clock.c b/arch/arm/mach-ep93xx/clock.c
index 5f80092b6ace..e29bdef9b2e2 100644
--- a/arch/arm/mach-ep93xx/clock.c
+++ b/arch/arm/mach-ep93xx/clock.c
@@ -96,6 +96,10 @@ static struct clk clk_keypad = {
96 .enable_mask = EP93XX_SYSCON_KEYTCHCLKDIV_KEN, 96 .enable_mask = EP93XX_SYSCON_KEYTCHCLKDIV_KEN,
97 .set_rate = set_keytchclk_rate, 97 .set_rate = set_keytchclk_rate,
98}; 98};
99static struct clk clk_spi = {
100 .parent = &clk_xtali,
101 .rate = EP93XX_EXT_CLK_RATE,
102};
99static struct clk clk_pwm = { 103static struct clk clk_pwm = {
100 .parent = &clk_xtali, 104 .parent = &clk_xtali,
101 .rate = EP93XX_EXT_CLK_RATE, 105 .rate = EP93XX_EXT_CLK_RATE,
@@ -186,6 +190,7 @@ static struct clk_lookup clocks[] = {
186 INIT_CK("ep93xx-ohci", NULL, &clk_usb_host), 190 INIT_CK("ep93xx-ohci", NULL, &clk_usb_host),
187 INIT_CK("ep93xx-keypad", NULL, &clk_keypad), 191 INIT_CK("ep93xx-keypad", NULL, &clk_keypad),
188 INIT_CK("ep93xx-fb", NULL, &clk_video), 192 INIT_CK("ep93xx-fb", NULL, &clk_video),
193 INIT_CK("ep93xx-spi.0", NULL, &clk_spi),
189 INIT_CK(NULL, "pwm_clk", &clk_pwm), 194 INIT_CK(NULL, "pwm_clk", &clk_pwm),
190 INIT_CK(NULL, "m2p0", &clk_m2p0), 195 INIT_CK(NULL, "m2p0", &clk_m2p0),
191 INIT_CK(NULL, "m2p1", &clk_m2p1), 196 INIT_CK(NULL, "m2p1", &clk_m2p1),
@@ -473,6 +478,14 @@ static int __init ep93xx_clock_init(void)
473 /* Initialize the pll2 derived clocks */ 478 /* Initialize the pll2 derived clocks */
474 clk_usb_host.rate = clk_pll2.rate / (((value >> 28) & 0xf) + 1); 479 clk_usb_host.rate = clk_pll2.rate / (((value >> 28) & 0xf) + 1);
475 480
481 /*
482 * EP93xx SSP clock rate was doubled in version E2. For more information
483 * see:
484 * http://www.cirrus.com/en/pubs/appNote/AN273REV4.pdf
485 */
486 if (ep93xx_chip_revision() < EP93XX_CHIP_REV_E2)
487 clk_spi.rate /= 2;
488
476 pr_info("PLL1 running at %ld MHz, PLL2 at %ld MHz\n", 489 pr_info("PLL1 running at %ld MHz, PLL2 at %ld MHz\n",
477 clk_pll1.rate / 1000000, clk_pll2.rate / 1000000); 490 clk_pll1.rate / 1000000, clk_pll2.rate / 1000000);
478 pr_info("FCLK %ld MHz, HCLK %ld MHz, PCLK %ld MHz\n", 491 pr_info("FCLK %ld MHz, HCLK %ld MHz, PCLK %ld MHz\n",
diff --git a/arch/arm/mach-ep93xx/core.c b/arch/arm/mach-ep93xx/core.c
index 8d3f77e9fa86..9092677f63eb 100644
--- a/arch/arm/mach-ep93xx/core.c
+++ b/arch/arm/mach-ep93xx/core.c
@@ -31,10 +31,12 @@
31#include <linux/amba/serial.h> 31#include <linux/amba/serial.h>
32#include <linux/i2c.h> 32#include <linux/i2c.h>
33#include <linux/i2c-gpio.h> 33#include <linux/i2c-gpio.h>
34#include <linux/spi/spi.h>
34 35
35#include <mach/hardware.h> 36#include <mach/hardware.h>
36#include <mach/fb.h> 37#include <mach/fb.h>
37#include <mach/ep93xx_keypad.h> 38#include <mach/ep93xx_keypad.h>
39#include <mach/ep93xx_spi.h>
38 40
39#include <asm/mach/map.h> 41#include <asm/mach/map.h>
40#include <asm/mach/time.h> 42#include <asm/mach/time.h>
@@ -430,6 +432,56 @@ void __init ep93xx_register_i2c(struct i2c_gpio_platform_data *data,
430 platform_device_register(&ep93xx_i2c_device); 432 platform_device_register(&ep93xx_i2c_device);
431} 433}
432 434
435/*************************************************************************
436 * EP93xx SPI peripheral handling
437 *************************************************************************/
438static struct ep93xx_spi_info ep93xx_spi_master_data;
439
440static struct resource ep93xx_spi_resources[] = {
441 {
442 .start = EP93XX_SPI_PHYS_BASE,
443 .end = EP93XX_SPI_PHYS_BASE + 0x18 - 1,
444 .flags = IORESOURCE_MEM,
445 },
446 {
447 .start = IRQ_EP93XX_SSP,
448 .end = IRQ_EP93XX_SSP,
449 .flags = IORESOURCE_IRQ,
450 },
451};
452
453static struct platform_device ep93xx_spi_device = {
454 .name = "ep93xx-spi",
455 .id = 0,
456 .dev = {
457 .platform_data = &ep93xx_spi_master_data,
458 },
459 .num_resources = ARRAY_SIZE(ep93xx_spi_resources),
460 .resource = ep93xx_spi_resources,
461};
462
463/**
464 * ep93xx_register_spi() - registers spi platform device
465 * @info: ep93xx board specific spi master info (__initdata)
466 * @devices: SPI devices to register (__initdata)
467 * @num: number of SPI devices to register
468 *
469 * This function registers platform device for the EP93xx SPI controller and
470 * also makes sure that SPI pins are muxed so that I2S is not using those pins.
471 */
472void __init ep93xx_register_spi(struct ep93xx_spi_info *info,
473 struct spi_board_info *devices, int num)
474{
475 /*
476 * When SPI is used, we need to make sure that I2S is muxed off from
477 * SPI pins.
478 */
479 ep93xx_devcfg_clear_bits(EP93XX_SYSCON_DEVCFG_I2SONSSP);
480
481 ep93xx_spi_master_data = *info;
482 spi_register_board_info(devices, num);
483 platform_device_register(&ep93xx_spi_device);
484}
433 485
434/************************************************************************* 486/*************************************************************************
435 * EP93xx LEDs 487 * EP93xx LEDs
diff --git a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
index 93e2ecc79ceb..b1e096f0c2d2 100644
--- a/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
+++ b/arch/arm/mach-ep93xx/include/mach/ep93xx-regs.h
@@ -106,6 +106,7 @@
106 106
107#define EP93XX_AAC_BASE EP93XX_APB_IOMEM(0x00080000) 107#define EP93XX_AAC_BASE EP93XX_APB_IOMEM(0x00080000)
108 108
109#define EP93XX_SPI_PHYS_BASE EP93XX_APB_PHYS(0x000a0000)
109#define EP93XX_SPI_BASE EP93XX_APB_IOMEM(0x000a0000) 110#define EP93XX_SPI_BASE EP93XX_APB_IOMEM(0x000a0000)
110 111
111#define EP93XX_IRDA_BASE EP93XX_APB_IOMEM(0x000b0000) 112#define EP93XX_IRDA_BASE EP93XX_APB_IOMEM(0x000b0000)
diff --git a/arch/arm/mach-ep93xx/include/mach/platform.h b/arch/arm/mach-ep93xx/include/mach/platform.h
index b663390b4d87..9a4413dd44bb 100644
--- a/arch/arm/mach-ep93xx/include/mach/platform.h
+++ b/arch/arm/mach-ep93xx/include/mach/platform.h
@@ -6,9 +6,11 @@
6 6
7struct i2c_gpio_platform_data; 7struct i2c_gpio_platform_data;
8struct i2c_board_info; 8struct i2c_board_info;
9struct spi_board_info;
9struct platform_device; 10struct platform_device;
10struct ep93xxfb_mach_info; 11struct ep93xxfb_mach_info;
11struct ep93xx_keypad_platform_data; 12struct ep93xx_keypad_platform_data;
13struct ep93xx_spi_info;
12 14
13struct ep93xx_eth_data 15struct ep93xx_eth_data
14{ 16{
@@ -44,6 +46,8 @@ unsigned int ep93xx_chip_revision(void);
44void ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr); 46void ep93xx_register_eth(struct ep93xx_eth_data *data, int copy_addr);
45void ep93xx_register_i2c(struct i2c_gpio_platform_data *data, 47void ep93xx_register_i2c(struct i2c_gpio_platform_data *data,
46 struct i2c_board_info *devices, int num); 48 struct i2c_board_info *devices, int num);
49void ep93xx_register_spi(struct ep93xx_spi_info *info,
50 struct spi_board_info *devices, int num);
47void ep93xx_register_fb(struct ep93xxfb_mach_info *data); 51void ep93xx_register_fb(struct ep93xxfb_mach_info *data);
48void ep93xx_register_pwm(int pwm0, int pwm1); 52void ep93xx_register_pwm(int pwm0, int pwm1);
49int ep93xx_pwm_acquire_gpio(struct platform_device *pdev); 53int ep93xx_pwm_acquire_gpio(struct platform_device *pdev);