* [PATCH 6/6] SMDK6410 SPI: Added spidev support as an example
@ 2009-11-21 2:52 Jassi Brar
2009-11-23 13:23 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: Jassi Brar @ 2009-11-21 2:52 UTC (permalink / raw)
To: linux-samsung-soc; +Cc: Jassi Brar
As an illustration of using the newly implemented SPI driver,
'spidev' master device has been enabled on SMDK6410.
Signed-off-by: Jassi Brar <jassi.brar@samsung.com>
---
arch/arm/mach-s3c6410/mach-smdk6410.c | 47 +++++++++++++++++++++++++++++++++
1 files changed, 47 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-s3c6410/mach-smdk6410.c b/arch/arm/mach-s3c6410/mach-smdk6410.c
index ea51dbe..1230fa9 100644
--- a/arch/arm/mach-s3c6410/mach-smdk6410.c
+++ b/arch/arm/mach-s3c6410/mach-smdk6410.c
@@ -25,6 +25,7 @@
#include <linux/gpio.h>
#include <linux/delay.h>
#include <linux/smsc911x.h>
+#include <linux/spi/spi.h>
#ifdef CONFIG_SMDK6410_WM1190_EV1
#include <linux/mfd/wm8350/core.h>
@@ -49,8 +50,10 @@
#include <plat/regs-gpio.h>
#include <plat/regs-sys.h>
#include <plat/iic.h>
+#include <plat/spi.h>
#include <plat/fb.h>
#include <plat/gpio-cfg.h>
+#include <plat/gpio-bank-c.h>
#include <plat/s3c6410.h>
#include <plat/clock.h>
@@ -193,6 +196,7 @@ static struct platform_device *smdk6410_devices[] __initdata = {
#ifdef CONFIG_SMDK6410_SD_CH1
&s3c_device_hsmmc1,
#endif
+ &s3c64xx_device_spi0,
&s3c_device_i2c0,
&s3c_device_i2c1,
&s3c_device_fb,
@@ -351,6 +355,40 @@ static struct i2c_board_info i2c_devs1[] __initdata = {
{ I2C_BOARD_INFO("24c128", 0x57), }, /* Samsung S524AD0XD1 */
};
+static void smdk6410_spidev_cs_set_level(int high)
+{
+ u32 val;
+
+ val = readl(S3C64XX_GPCDAT);
+
+ if (high)
+ val |= (1<<3);
+ else
+ val &= ~(1<<3);
+
+ writel(val, S3C64XX_GPCDAT);
+}
+
+#define SMDK6410_SPIDEV_CS 0
+
+static struct s3c64xx_spi_csinfo smdk6410_spi0_csi[] = {
+ [SMDK6410_SPIDEV_CS] = {
+ .set_level = smdk6410_spidev_cs_set_level,
+ .fb_delay = 0x3, /* 9ns feedback delay */
+ },
+};
+
+static struct spi_board_info smdk6410_spi_devices[] __initdata = {
+ {
+ .modalias = "spidev",
+ .mode = SPI_MODE_0,
+ .max_speed_hz = 4000000,
+ .bus_num = 0,
+ .chip_select = 0,
+ .controller_data = &smdk6410_spi1_csi[SMDK6410_SPIDEV_CS],
+ },
+};
+
static void __init smdk6410_map_io(void)
{
u32 tmp;
@@ -385,6 +423,15 @@ static void __init smdk6410_machine_init(void)
i2c_register_board_info(0, i2c_devs0, ARRAY_SIZE(i2c_devs0));
i2c_register_board_info(1, i2c_devs1, ARRAY_SIZE(i2c_devs1));
+ /* SPI Controller-0 generates its clocks from PCLK and
+ * emulates ARRAY_SIZE(smdk6410_spi0_csi) chipselects.
+ */
+ s3c64xx_spi_set_info(BUSNUM(0), S3C64XX_SPI_SRCCLK_PCLK,
+ ARRAY_SIZE(smdk6410_spi0_csi));
+
+ spi_register_board_info(smdk6410_spi_devices,
+ ARRAY_SIZE(smdk6410_spi_devices));
+
platform_add_devices(smdk6410_devices, ARRAY_SIZE(smdk6410_devices));
}
--
1.6.2.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 6/6] SMDK6410 SPI: Added spidev support as an example
2009-11-21 2:52 [PATCH 6/6] SMDK6410 SPI: Added spidev support as an example Jassi Brar
@ 2009-11-23 13:23 ` Mark Brown
2009-11-23 13:41 ` jassi brar
0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2009-11-23 13:23 UTC (permalink / raw)
To: Jassi Brar; +Cc: linux-samsung-soc
On Sat, Nov 21, 2009 at 11:52:28AM +0900, Jassi Brar wrote:
> +static void smdk6410_spidev_cs_set_level(int high)
> +{
> + u32 val;
> +
> + val = readl(S3C64XX_GPCDAT);
> +
> + if (high)
> + val |= (1<<3);
> + else
> + val &= ~(1<<3);
> +
> + writel(val, S3C64XX_GPCDAT);
> +}
This should be using gpiolib, I suspect.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6/6] SMDK6410 SPI: Added spidev support as an example
2009-11-23 13:23 ` Mark Brown
@ 2009-11-23 13:41 ` jassi brar
2009-11-23 13:43 ` Mark Brown
0 siblings, 1 reply; 4+ messages in thread
From: jassi brar @ 2009-11-23 13:41 UTC (permalink / raw)
To: Mark Brown; +Cc: Jassi Brar, linux-samsung-soc
On Mon, Nov 23, 2009 at 10:23 PM, Mark Brown
<broonie@opensource.wolfsonmicro.com> wrote:
> On Sat, Nov 21, 2009 at 11:52:28AM +0900, Jassi Brar wrote:
>
>> +static void smdk6410_spidev_cs_set_level(int high)
>> +{
>> + u32 val;
>> +
>> + val = readl(S3C64XX_GPCDAT);
>> +
>> + if (high)
>> + val |= (1<<3);
>> + else
>> + val &= ~(1<<3);
>> +
>> + writel(val, S3C64XX_GPCDAT);
>> +}
>
> This should be using gpiolib, I suspect.
yes, that wud be more appropriate. thanks.
Also, i anticipate objections to the utility of a spidev device when
smdk6410 doesn't even have convenient pins to tap the SPI signals.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 6/6] SMDK6410 SPI: Added spidev support as an example
2009-11-23 13:41 ` jassi brar
@ 2009-11-23 13:43 ` Mark Brown
0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2009-11-23 13:43 UTC (permalink / raw)
To: jassi brar; +Cc: Jassi Brar, linux-samsung-soc
On Mon, Nov 23, 2009 at 10:41:40PM +0900, jassi brar wrote:
> Also, i anticipate objections to the utility of a spidev device when
> smdk6410 doesn't even have convenient pins to tap the SPI signals.
It does have the expansion ports under the LCD, though.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-11-23 13:43 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-21 2:52 [PATCH 6/6] SMDK6410 SPI: Added spidev support as an example Jassi Brar
2009-11-23 13:23 ` Mark Brown
2009-11-23 13:41 ` jassi brar
2009-11-23 13:43 ` Mark Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.