|
From: | Kevin Wells |
Subject: | RE: [Ltib] SPI missing |
Date: | Wed, 1 Sep 2010 00:43:03 +0200 |
Hi Jorge, You can try this patch for FDI and 2.6.27.8. It adds SPIDEV
support and fixes a few other things. If you do use it, you’ll need to add the
ethaddr=00:01:02:03:04:05 parameters to bootargs in u-boot. Pick your own MAC
address. thanks, Kevin diff -Naur -X linux-2.6.27.8/Documentation/dontdiff
linux-2.6.27.8-orig/arch/arm/mach-lpc32xx/board-arm9dimm3250.c
linux-2.6.27.8/arch/arm/mach-lpc32xx/board-arm9dimm3250.c ---
linux-2.6.27.8-orig/arch/arm/mach-lpc32xx/board-arm9dimm3250.c 2010-08-31 08:20:09.411260348
-0700 +++ linux-2.6.27.8/arch/arm/mach-lpc32xx/board-arm9dimm3250.c 2010-08-31
08:32:26.769260136 -0700 @@ -29,6 +29,7 @@ #include <linux/input.h> #include <linux/device.h> #include <linux/delay.h> +#include <linux/spi/spi.h> #include <mach/hardware.h> #include <asm/setup.h> @@ -51,23 +52,6 @@ #define BOARDDEBUG /* - * Structure used to define the hardware for the Phytec board.
This - * is obtained from index (SOM9DIMM3250_SEEPROM_CFGOFS) in the
AT25 serial - * EEPROM. The .fieldval value must be checked for the correct
value - * (ARM9DIMM_HW_VER_VAL) or the sturcture is invalid. - */ -typedef struct -{ - u32 dramcfg; /* DRAM config word */ - u32 syscfg; /* Configuration word */ - /* MAC address, use lower 6 bytes only, index 0 is first byte
*/ - u8 mac[8]; /* Only the first 6 are used */ - u32 rsvd [5]; /* Reserved, must be 0 */ - u32 fieldvval; /* Must be ARM9DIMM_HW_VER_VAL */ -} ARM9DIMM_HW_T; -static ARM9DIMM_HW_T arm9dimmhwdata; - -/* * Serial EEPROM support */ #define ARM9DIMM_HW_VER_VAL 0x000A3250 @@ -264,11 +248,14 @@ }, }; +static u64 lpc32xx_slc_dma_mask = 0xffffffffUL; static struct platform_device slc_nand_device = { .name =
"lpc32xx-nand", .id = 0, .dev = { .platform_data =
&lpc32xx_nandcfg, + .dma_mask =
&lpc32xx_slc_dma_mask, + .coherent_dma_mask = ~0UL, }, .num_resources =
ARRAY_SIZE(slc_nand_resources), .resource = slc_nand_resources, @@ -436,25 +423,41 @@ * Network configuration structure */ #if defined (CONFIG_LPC32XX_MII) -static int return_mac_address(u8 *mac) +/* MAC address is provided as a boot paramter (ethaddr) via
u-boot */ +static u8 mac_address[6] = {0x00, 0x1a, 0xf1, 0x00, 0x00,
0x00}; + +static int __init set_ethaddr(char *str) { - int ret = 0; + char *s, *e; int i; - if (arm9dimmhwdata.fieldvval !=
ARM9DIMM_HW_VER_VAL) - { - /* Field has garbage in it */ - printk(KERN_ERR "Invalid
ethernet MAC address\n"); - ret = -ENODEV; - } + s = str; - /* Use MAC address from hardware descriptor */ - for (i = 0; i < 6; i++) - { - mac [i] = arm9dimmhwdata.mac [i]; + for (i = 0; i < 6; ++i) { + mac_address[i] = s ?
simple_strtoul (s, &e, 16) : 0; + if (s) + s = (*e) ? e + 1 :
e; } - return ret; + return 1; +} + +static int __init ea_ethaddr_new(char *str) +{ + return set_ethaddr(str); +} +__setup("ethaddr=", ea_ethaddr_new); + +static int return_mac_address(u8 *mac) +{ + mac[0] = mac_address[0]; + mac[1] = mac_address[1]; + mac[2] = mac_address[2]; + mac[3] = mac_address[3]; + mac[4] = mac_address[4]; + mac[5] = mac_address[5]; + + return 0; } struct lpc32xx_net_cfg lpc32xx_netdata = @@ -550,58 +553,89 @@ }; #endif -#if defined(CONFIG_RTC_DRV_PCF8563) -static struct i2c_board_info __initdata
arm9dimm3250_i2c_board_info [] = { - { - I2C_BOARD_INFO("rtc-pcf8563",
0x51), - }, -}; -#endif - -static struct i2c_board_info __initdata
armtskit_i2c2_board_info[] = { - { - I2C_BOARD_INFO("pca24s08",
0x54), - }, -}; - -/* - * Load the board hardware descriptor from the serial EEPROM - */ -static void __init arm9dimm3250_load_hw_desc(void) +#if defined(CONFIG_SPI_LPC32XX) +static void fdi_spi_cs_setup(int cs) { - u32 svclk, tmp, addr; - int i, len; - u8 *p8, cmd [4], in [4]; - - // Setup default values for the arm9dimmhwdata structure - arm9dimmhwdata.dramcfg = 1; - arm9dimmhwdata.syscfg = 2; - arm9dimmhwdata.mac[0] = 0x00; - arm9dimmhwdata.mac[1] = 0x11; - arm9dimmhwdata.mac[2] = 0x22; - arm9dimmhwdata.mac[3] = 0x33; - arm9dimmhwdata.mac[4] = 0x44; - arm9dimmhwdata.mac[5] = 0x55; - arm9dimmhwdata.fieldvval = ARM9DIMM_HW_VER_VAL; + /* Setup SPI CS0 as an output on GPIO5 */ + __raw_writel((1 << 5),
GPIO_P2_MUX_CLR(GPIO_IOBASE)); - if (arm9dimmhwdata.fieldvval !=
ARM9DIMM_HW_VER_VAL) + /* Set chip select high */ + __raw_writel(OUTP_STATE_GPIO(5), + GPIO_P3_OUTP_SET(GPIO_IOBASE)); +} +static int fdi_spi_cs_set(int cs, int state) +{ + if (cs == 0) { - printk(KERN_ERR "Invalid
board descriptor!\n"); + if (state != 0) + { + /* Set chip select
high */ + __raw_writel(OUTP_STATE_GPIO(5), + GPIO_P3_OUTP_SET(GPIO_IOBASE)); + } + else + { + /* Set chip select
low */ + __raw_writel(OUTP_STATE_GPIO(5), + GPIO_P3_OUTP_CLR(GPIO_IOBASE)); + } } -#if defined (BOARDDEBUG) else { - printk(KERN_INFO "Hardware
descriptor info:\n"); - printk(KERN_INFO " DRAM
config word: 0x%08x\n", arm9dimmhwdata.dramcfg); - printk(KERN_INFO " syscfg
word: 0x%08x\n", arm9dimmhwdata.syscfg); - printk(KERN_INFO " fieldval
word: 0x%08x\n", arm9dimmhwdata.fieldvval); - printk(KERN_INFO " MAC
address: "); - printk(KERN_INFO
"%02x:%02x:%02x:%02x:%02x:%02x\n", - arm9dimmhwdata.mac
[0], arm9dimmhwdata.mac [1], arm9dimmhwdata.mac [2], - arm9dimmhwdata.mac
[3], arm9dimmhwdata.mac [4], arm9dimmhwdata.mac [5]); + /* Invalid chip select */ + return -ENODEV; } + + return 0; +} + +struct lpc32xx_spi_cfg lpc32xx_spi0data = +{ + .num_cs = 1, /* Only
1 chip select */ + .spi_cs_setup = &fdi_spi_cs_setup, + .spi_cs_set = &fdi_spi_cs_set, +}; + +/* SPI driver registration */ +static int __init fdi_spi_board_register(void) +{ +#if defined(CONFIG_SPI_SPIDEV) || defined(CONFIG_SPI_SPIDEV_MODULE) + struct spi_board_info info = + { + .modalias = "spidev", + .max_speed_hz = 5000000, + .bus_num = 0, + .chip_select = 0, + }; + + return spi_register_board_info(&info, 1); #endif } +arch_initcall(fdi_spi_board_register); + +static struct resource ssp0_resources[] = { + [0] = { + .start = SSP0_BASE, + .end = SSP0_BASE + SZ_4K -
1, + .flags = IORESOURCE_MEM, + }, + [1] = { + .start = IRQ_SSP0, + .end = IRQ_SSP0, + .flags = IORESOURCE_IRQ, + }, + +}; +static struct platform_device ssp0_device = { + .name = "spi_lpc32xx", + .id = 0, + .dev = { + .platform_data =
&lpc32xx_spi0data, + }, + .num_resources =
ARRAY_SIZE(ssp0_resources), + .resource = ssp0_resources, +}; +#endif static struct platform_device* arm9dimm3250_devs[] __initdata =
{ #if defined(CONFIG_SPI_LPC32XX) @@ -669,22 +703,12 @@ tmp |= CLKPWR_I2CCLK_USBI2CHI_DRIVE |
CLKPWR_I2CCLK_I2C2HI_DRIVE | CLKPWR_I2CCLK_I2C1HI_DRIVE; __raw_writel(tmp, CLKPWR_I2C_CLK_CTRL(CLKPWR_IOBASE)); - /* Enable DMA for I2S1 channel */ - tmp =
__raw_readl(CLKPWR_I2S_CLK_CTRL(CLKPWR_IOBASE)); - tmp = CLKPWR_I2SCTRL_I2S1_USE_DMA; - __raw_writel(tmp,
CLKPWR_I2S_CLK_CTRL(CLKPWR_IOBASE)); - - /* Load the board hardware descriptor, as some
other board functions - require it's data */ - arm9dimm3250_load_hw_desc(); - /* Call chip specific init */ lpc32xx_init(); /* Add board platform devices */ platform_add_devices (arm9dimm3250_devs,
ARRAY_SIZE (arm9dimm3250_devs)); - #if defined(CONFIG_MMC_ARMMMCI) /* Enable SD card clock so AMBA driver will work
correctly. The AMBA driver needs the clock before the SD
card controller @@ -712,20 +736,6 @@ tmp =
__raw_readl(UARTCTL_CTRL(io_p2v(UART_CTRL_BASE))); tmp &= ~UART_U5_ROUTE_TO_USB; __raw_writel(tmp,
UARTCTL_CTRL(io_p2v(UART_CTRL_BASE))); - -#if defined (CONFIG_SND_LPC3XXX_SOC) - /* Test clock needed for UDA1380 */ - __raw_writel((CLKPWR_TESTCLK2_SEL_MOSC |
CLKPWR_TESTCLK_TESTCLK2_EN), - CLKPWR_TEST_CLK_SEL(CLKPWR_IOBASE)); -#endif - -#if defined(CONFIG_RTC_DRV_PCF8563) - /* I2C based RTC device on I2C1 */ -// i2c_register_board_info(0,
arm9dimm3250_i2c_board_info, -// ARRAY_SIZE(arm9dimm3250_i2c_board_info)); -#endif -// i2c_register_board_info(1,
armtskit_i2c2_board_info, -// ARRAY_SIZE(armtskit_i2c2_board_info)); } MACHINE_START (LPC3XXX, "FDI ARM-TS-KIT 3250 board with
the LPC3250 Microcontroller") From: Jorge A. Castro
[mailto:address@hidden Hi Kevin, Hi Jorge, I’ll (try to) post a patch for this later today. Better yet,
I’ll post a patch that adds full 2.6.34 support on the LTIB menu for the FDI
board next week! thanks, Kevin Subject: Re: [Ltib] SPI missing Hi Kevin, Hi Jorge, I just looked at the FDI support for SPI and it’s not in the
board-arm9dimm3250.c file. The SPI interface won’t work without a platform driver
registered for it. This is what I found in the file… 606 static struct platform_device* arm9dimm3250_devs[]
__initdata = { 607 #if defined(CONFIG_SPI_LPC32XX) 608
&ssp0_device, 609 #endif 610 #if defined(CONFIG_KEYBOARD_LPC32XX) 611
&kscan_device, 612 #endif But there is no matching ssp0_device platform structure for it.
I would expect this to generate a compilation error on failure, so the
CONFIG_SPI_LPC32XX macro check might be a suspect too. Try removing the #id/#endif check and recompiling.. 606 static struct platform_device* arm9dimm3250_devs[]
__initdata = { 608
&ssp0_device, 610 #if defined(CONFIG_KEYBOARD_LPC32XX) 611
&kscan_device, 612 #endif Also add the necessary SPI support above this file. You will
also need to register your SPI devices. This doesn’t seem to be there either. You can use the phytec board file as a reference for spi
registration. It is here: http://git.lpclinux.com/?p=linux-2.6.27.8-lpc32xx.git;a=blob;f=arch/arm/mach-lpc32xx/board-phy3250.c;h=90d818d42d563665219ede8c2e7f5bc4bbcac7ca;hb=ee7393fba54ad123efaf536e51e139fefd9c85ab The FDI port is in need of a boot loader and kernel update! thanks, Kevin From: Jorge A. Castro [mailto:address@hidden]
Hi Kevin, Hi Jorge, <*> Bitbanging SPI master You can remove this (unless you’ve added the logic to support
GPIO based SPI). There is no default GPIO setup for this in the 32x0. You may need to manually create the device node. I use sysfs to
determine the node numbers for the device. address@hidden /]# cd /sys/class/spi_master/spi0/device/spi0.0/ address@hidden spi0.0]# ls bus
modalias
spidev:spidev0.0 uevent driver
power
subsystem address@hidden spi0.0]# cat modalias spidev address@hidden spi0.0]# cat spidev\:spidev0.0/ spidev:spidev0.0/dev
spidev:spidev0.0/subsystem/ spidev:spidev0.0/device/
spidev:spidev0.0/uevent spidev:spidev0.0/power/ address@hidden spi0.0]# cat spidev\:spidev0.0/dev 153:0 address@hidden spi0.0]# Then I create the node… address@hidden spi0.0]# mknod /dev/spi0 c 153 0 address@hidden spi0.0]# cat /dev/spi0 ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ Maybe I’ll stick this in ./merge thanks, Kevin From: address@hidden
[mailto:address@hidden]
On Behalf Of Jorge A. Castro Hi everyone, I had enable most of related
with SPI in order to try to communicate to an specific module. I'm using Future
Designs LPC3250 development kit.
-- Jorge A. Castro Canam-Technology, Inc.
-- Jorge A. Castro Canam-Technology, Inc.
-- Jorge A. Castro Canam-Technology, Inc.
-- Jorge A. Castro Canam-Technology, Inc. |
[Prev in Thread] | Current Thread | [Next in Thread] |