Re: [PATCH] DM365EVM: Fix up PHY Clocksource to enable USB Host on DM365EVM
Hi Kieran, 2010/6/8 Kieran Bingham kieranbing...@gmail.com From: Kieran Bingham kbing...@mpc-data.co.uk This patch was created by pulling in the code required from the Arago Tree. Checked by running on a Spectrum Digital DM365EVM Revision C. Signed-off-by: Kieran Bingham kbing...@mpc-data.co.uk --- arch/arm/mach-davinci/board-dm365-evm.c | 13 + drivers/usb/musb/davinci.c | 12 drivers/usb/musb/davinci.h |4 3 files changed, 29 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index fdb073e..c4a05fc 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -18,6 +18,7 @@ #include linux/i2c.h #include linux/io.h #include linux/clk.h +#include linux/gpio.h #include linux/i2c/at24.h #include linux/leds.h #include linux/mtd/mtd.h @@ -39,6 +40,7 @@ #include mach/mmc.h #include mach/nand.h #include mach/keyscan.h +#include mach/usb.h #include media/tvp514x.h @@ -590,6 +592,15 @@ static struct spi_board_info dm365_evm_spi_info[] __initconst = { }, }; +static void dm365evm_usb_configure(void) +{ + davinci_cfg_reg(DM365_GPIO33); + gpio_request(33, usb); + gpio_direction_output(33, 1); + davinci_setup_usb(500, 8); +} + + static __init void dm365_evm_init(void) { evm_init_i2c(); @@ -607,6 +618,8 @@ static __init void dm365_evm_init(void) dm365_init_rtc(); dm365_init_ks(dm365evm_ks_data); + dm365evm_usb_configure(); + dm365_init_spi0(BIT(0), dm365_evm_spi_info, ARRAY_SIZE(dm365_evm_spi_info)); } diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index ce2e16f..3736792 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -64,6 +64,16 @@ static inline void phy_on(void) /* power everything up; start the on-chip PHY and its PLL */ phy_ctrl = ~(USBPHY_OSCPDWN | USBPHY_OTGPDWN | USBPHY_PHYPDWN); phy_ctrl |= USBPHY_SESNDEN | USBPHY_VBDTCTEN | USBPHY_PHYPLLON; + + if (cpu_is_davinci_dm365()) { + /* +* DM365 PHYCLKFREQ field [15:12] is set to 2 +* to get clock from 24MHz crystal +*/ + phy_ctrl |= USBPHY_CLKFREQ_24MHZ; + /*phy_ctrl = ~USBPHY_PHYPDWN;*/ + } + __raw_writel(phy_ctrl, USB_PHY_CTRL); /* wait for PLL to lock before proceeding */ @@ -188,6 +198,8 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate) if (immediate) vbus_state = is_on; #endif + if (cpu_is_davinci_dm365()) + gpio_set_value(33, is_on); } static void davinci_set_vbus(struct musb *musb, int is_on) diff --git a/drivers/usb/musb/davinci.h b/drivers/usb/musb/davinci.h index 046c844..0577ec6 100644 --- a/drivers/usb/musb/davinci.h +++ b/drivers/usb/musb/davinci.h @@ -16,6 +16,10 @@ /* Integrated highspeed/otg PHY */ #define USBPHY_CTL_PADDR (DAVINCI_SYSTEM_MODULE_BASE + 0x34) +#define USBPHY_NDATAPOLBIT(18) +#define USBPHY_SESSION_VBUSBIT(17) +#define USBPHY_PERI_USBID BIT(16) +#define USBPHY_CLKFREQ_24MHZ BIT(13) #define USBPHY_DATAPOL BIT(11) /* (dm355) switch D+/D- */ #define USBPHY_PHYCLKGDBIT(8) #define USBPHY_SESNDEN BIT(7) /* v(sess_end) comparator */ -- 1.6.2.1 ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source I have applied and tested your patch. On the target: modprobe g_cdc or modprobe g_ether ifconfig usb0 128.16.0.1 netmask 255.255.224.0 and on the ubuntu host: ifconfig usb0 128.16.0.2 netmask 255.255.224.0 Instead the win-xp host can't do get_descriptor. I've tested also with beagle sniffer. With win-xp host I get only: and the win-xp thinks to see null vid and pids. = musb_hdrc: version 6.0, pio, peripheral, debug=0 musb_hdrc: ConfigData=0x06 (UTMI-8, dyn FIFOs, SoftConn) musb_hdrc: MHDRC RTL version 1.500 musb_hdrc: setup fifo_mode 2 musb_hdrc: 7/9 max ep, 2624/4096 memory musb_hdrc musb_hdrc: USB Peripheral mode controller at fec64000 using PIO, IRQ 12 g_ether gadget: using random self ethernet address g_ether gadget: using random host ethernet address usb0: MAC 82:aa:9e:2a:87:e1 usb0: HOST MAC 6a:eb:1b:a6:67:69 g_ether gadget: Ethernet Gadget, version: Memorial Day 2008 g_ether gadget: g_ether ready musb_stage0_irq 384: == Power=f0, DevCtl=99, int_usb=0x4 musb_stage0_irq 767: BUS RESET as b_idle musb_g_reset 2013: == B-Device addr=0 driver 'g_ether' musb_stage0_irq 384: == Power=f0, DevCtl=99, int_usb=0x4 musb_stage0_irq 767: BUS RESET as b_peripheral
RE: [PATCH 14/14] davinci: video: davincifb Parallel RBG LCD management
Hi, Why are you trying to fix this old fb driver when TI India is already working on to up port the latest Arago fb and v4l2 drivers? davincifb driver is not part of the kernel.org tree and is available only in davinci tree and is an obsolete driver. Murali Karicheri Software Design Engineer Texas Instruments Inc. Germantown, MD 20874 phone: 301-407-9583 email: m-kariche...@ti.com -Original Message- From: davinci-linux-open-source-boun...@linux.davincidsp.com [mailto:davinci-linux-open-source-boun...@linux.davincidsp.com] On Behalf Of Raffaele Recalcati Sent: Friday, June 11, 2010 6:20 AM To: davinci-linux-open-source@linux.davincidsp.com Subject: [PATCH 14/14] davinci: video: davincifb Parallel RBG LCD management From: Davide Bonfanti davide.bonfa...@bticino.it Signed-off-by: Davide Bonfanti davide.bonfa...@bticino.it --- drivers/video/davincifb.c | 167 + include/video/davincifb.h | 17 - 2 files changed, 165 insertions(+), 19 deletions(-) diff --git a/drivers/video/davincifb.c b/drivers/video/davincifb.c index 2a7b2c9..24d1424 100644 --- a/drivers/video/davincifb.c +++ b/drivers/video/davincifb.c @@ -29,12 +29,15 @@ #include linux/interrupt.h #include linux/platform_device.h +#include media/davinci/vpss.h #include asm/irq.h #include asm/uaccess.h #include video/davincifb.h #include asm/system.h +#include mach/dm365.h +#include mach/cputype.h #define MODULE_NAME davincifb /* Output Format Selection */ @@ -286,6 +289,10 @@ static irqreturn_t davincifb_isr(int irq, void *arg) dm-vid1-info.fix.line_length); dm-vid1-sdram_address = 0; } + if (dm-osd0-info.var.vmode == FB_VMODE_NONINTERLACED) { + ++dm-vsync_cnt; + wake_up_interruptible(dm-vsync_wait); + } return IRQ_HANDLED; } else { ++dm-vsync_cnt; @@ -631,21 +638,29 @@ static void set_sdram_params(char *id, u32 addr, u32 line_length) /* The parameters to be written to the registers should be in * multiple of 32 bytes */ - addr = addr;/* div by 32 */ - line_length = line_length / 32; + addr = (addr - DAVINCI_DDR_BASE) 5; /* div by 32 */ + line_length = line_length 5; if (is_win(id, VID0)) { - dispc_reg_out(OSD_VIDWIN0ADR, addr); - dispc_reg_out(OSD_VIDWIN0OFST, line_length); + dispc_reg_out(OSD_VIDWIN0ADR, addr 0x); + dispc_reg_merge(OSD_VIDWINADH, (addr 0x7F) 16, 0x7F); + dispc_reg_out(OSD_VIDWIN0OFST, line_length | 0x1000); + /* From docs it's not clear why bit12 is needed */ } else if (is_win(id, VID1)) { - dispc_reg_out(OSD_VIDWIN1ADR, addr); - dispc_reg_out(OSD_VIDWIN1OFST, line_length); + dispc_reg_out(OSD_VIDWIN1ADR, addr 0x); + dispc_reg_merge(OSD_VIDWINADH, (addr 0x7F) 8, 0x7F00); + dispc_reg_out(OSD_VIDWIN1OFST, line_length | 0x1000); + /* From docs it's not clear why bit12 is needed */ } else if (is_win(id, OSD0)) { - dispc_reg_out(OSD_OSDWIN0ADR, addr); - dispc_reg_out(OSD_OSDWIN0OFST, line_length); + dispc_reg_out(OSD_OSDWIN0ADR, addr 0x); + dispc_reg_out(OSD_OSDWIN0OFST, line_length | 0x1000); + dispc_reg_merge(OSD_OSDWINADH, (addr 0x7F) 16, 0x7F); + /* From docs it's not clear why bit12 is needed */ } else if (is_win(id, OSD1)) { - dispc_reg_out(OSD_OSDWIN1ADR, addr); - dispc_reg_out(OSD_OSDWIN1OFST, line_length); + dispc_reg_out(OSD_OSDWIN1ADR, addr 0x); + dispc_reg_merge(OSD_OSDWINADH, (addr 0x7F) 8, 0x7F00); + dispc_reg_out(OSD_OSDWIN1OFST, line_length | 0x1000); + /* From docs it's not clear why bit12 is needed */ } } @@ -980,14 +995,12 @@ int __init davincifb_setup(char *options) if (!strncmp(this_opt, output=, 7)) { if (!strncmp(this_opt + 7, lcd, 3)) { dmparams.output = LCD; - dmparams.format = 0; + dmparams.format = RGB; } else if (!strncmp(this_opt + 7, ntsc, 4)) dmparams.output = NTSC; else if (!strncmp(this_opt + 7, pal, 3)) dmparams.output = PAL; } else if (!strncmp(this_opt, format=, 7)) { - if (dmparams.output == LCD) - continue; if (!strncmp(this_opt + 7, composite, 9)) dmparams.format = COMPOSITE; else if
Re: [PATCH] DM365EVM: Fix up PHY Clocksource to enable USB Host on DM365EVM
Hi Raffaele, I'm afraid I'm only using the USB in Host Mode - I have not looked at anything in gadget mode. Have you tried using the Arago Tree yet ? -- Regards Kieran Raffaele Recalcati wrote: Hi Kieran, 2010/6/8 Kieran Bingham kieranbing...@gmail.com From: Kieran Bingham kbing...@mpc-data.co.uk This patch was created by pulling in the code required from the Arago Tree. Checked by running on a Spectrum Digital DM365EVM Revision C. Signed-off-by: Kieran Bingham kbing...@mpc-data.co.uk --- arch/arm/mach-davinci/board-dm365-evm.c | 13 + drivers/usb/musb/davinci.c | 12 drivers/usb/musb/davinci.h |4 3 files changed, 29 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-davinci/board-dm365-evm.c b/arch/arm/mach-davinci/board-dm365-evm.c index fdb073e..c4a05fc 100644 --- a/arch/arm/mach-davinci/board-dm365-evm.c +++ b/arch/arm/mach-davinci/board-dm365-evm.c @@ -18,6 +18,7 @@ #include linux/i2c.h #include linux/io.h #include linux/clk.h +#include linux/gpio.h #include linux/i2c/at24.h #include linux/leds.h #include linux/mtd/mtd.h @@ -39,6 +40,7 @@ #include mach/mmc.h #include mach/nand.h #include mach/keyscan.h +#include mach/usb.h #include media/tvp514x.h @@ -590,6 +592,15 @@ static struct spi_board_info dm365_evm_spi_info[] __initconst = { }, }; +static void dm365evm_usb_configure(void) +{ + davinci_cfg_reg(DM365_GPIO33); + gpio_request(33, usb); + gpio_direction_output(33, 1); + davinci_setup_usb(500, 8); +} + + static __init void dm365_evm_init(void) { evm_init_i2c(); @@ -607,6 +618,8 @@ static __init void dm365_evm_init(void) dm365_init_rtc(); dm365_init_ks(dm365evm_ks_data); + dm365evm_usb_configure(); + dm365_init_spi0(BIT(0), dm365_evm_spi_info, ARRAY_SIZE(dm365_evm_spi_info)); } diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index ce2e16f..3736792 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -64,6 +64,16 @@ static inline void phy_on(void) /* power everything up; start the on-chip PHY and its PLL */ phy_ctrl = ~(USBPHY_OSCPDWN | USBPHY_OTGPDWN | USBPHY_PHYPDWN); phy_ctrl |= USBPHY_SESNDEN | USBPHY_VBDTCTEN | USBPHY_PHYPLLON; + + if (cpu_is_davinci_dm365()) { + /* +* DM365 PHYCLKFREQ field [15:12] is set to 2 +* to get clock from 24MHz crystal +*/ + phy_ctrl |= USBPHY_CLKFREQ_24MHZ; + /*phy_ctrl = ~USBPHY_PHYPDWN;*/ + } + __raw_writel(phy_ctrl, USB_PHY_CTRL); /* wait for PLL to lock before proceeding */ @@ -188,6 +198,8 @@ static void davinci_source_power(struct musb *musb, int is_on, int immediate) if (immediate) vbus_state = is_on; #endif + if (cpu_is_davinci_dm365()) + gpio_set_value(33, is_on); } static void davinci_set_vbus(struct musb *musb, int is_on) diff --git a/drivers/usb/musb/davinci.h b/drivers/usb/musb/davinci.h index 046c844..0577ec6 100644 --- a/drivers/usb/musb/davinci.h +++ b/drivers/usb/musb/davinci.h @@ -16,6 +16,10 @@ /* Integrated highspeed/otg PHY */ #define USBPHY_CTL_PADDR (DAVINCI_SYSTEM_MODULE_BASE + 0x34) +#define USBPHY_NDATAPOLBIT(18) +#define USBPHY_SESSION_VBUSBIT(17) +#define USBPHY_PERI_USBID BIT(16) +#define USBPHY_CLKFREQ_24MHZ BIT(13) #define USBPHY_DATAPOL BIT(11) /* (dm355) switch D+/D- */ #define USBPHY_PHYCLKGDBIT(8) #define USBPHY_SESNDEN BIT(7) /* v(sess_end) comparator */ -- 1.6.2.1 ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source I have applied and tested your patch. On the target: modprobe g_cdc or modprobe g_ether ifconfig usb0 128.16.0.1 netmask 255.255.224.0 and on the ubuntu host: ifconfig usb0 128.16.0.2 netmask 255.255.224.0 Instead the win-xp host can't do get_descriptor. I've tested also with beagle sniffer. With win-xp host I get only: and the win-xp thinks to see null vid and pids. = musb_hdrc: version 6.0, pio, peripheral, debug=0 musb_hdrc: ConfigData=0x06 (UTMI-8, dyn FIFOs, SoftConn) musb_hdrc: MHDRC RTL version 1.500 musb_hdrc: setup fifo_mode 2 musb_hdrc: 7/9 max ep, 2624/4096 memory musb_hdrc musb_hdrc: USB Peripheral mode controller at fec64000 using PIO, IRQ 12 g_ether gadget: using random self ethernet address g_ether gadget: using random host ethernet address usb0: MAC 82:aa:9e:2a:87:e1 usb0: HOST MAC 6a:eb:1b:a6:67:69 g_ether gadget: Ethernet Gadget, version: Memorial Day 2008 g_ether gadget: g_ether ready musb_stage0_irq 384: == Power=f0, DevCtl=99, int_usb=0x4 musb_stage0_irq 767: BUS RESET as b_idle musb_g_reset 2013: == B-Device addr=0 driver
RE: [PATCH 0/3] davinci: spi: replace existing SPI driver
I have compiled with the davinci_all_defconfig, but I don't have EVMs for the other davinci platforms to test with. I was testing this series on OMAP-L137, OMAP-L138 and DM365 EVMs and I found that on all these EVMS, Interrupt mode has problems. Driver works fine in DMA and POLL modes. Some problems which I had observed with the old driver are gone now. Do you have any idea what errors you're seeing in interrupt mode? I went and retested interrupt mode with several devices on my custom board and it still appeared to be working fine. It may be an interaction with code outside the driver because I'm running the identical driver code but I'm not running the latest kernel from the davinci git repository. I'm trying to figure out if I can get my DA850 EVM back into a state where I can debug this. Thanks for any hints you can give! ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
RE: [PATCH 2/3] davinci: spi: add replacement SPI driver
diff --git a/arch/arm/mach-davinci/include/mach/spi.h b/arch/arm/mach-davinci/include/mach/spi.h index 910efbf..10c39d8 100644 --- a/arch/arm/mach-davinci/include/mach/spi.h +++ b/arch/arm/mach-davinci/include/mach/spi.h @@ -19,26 +19,39 @@ #ifndef __ARCH_ARM_DAVINCI_SPI_H #define __ARCH_ARM_DAVINCI_SPI_H +#define SPI_INTERN_CS 0xFF + +/* resource flags for IORESOURCE_DMA resources */ +#define IORESOURCE_DMA_RX_CHAN 0x01 +#define IORESOURCE_DMA_TX_CHAN 0x02 +#define IORESOURCE_DMA_EVENT_Q 0x04 + enum { - SPI_VERSION_1, /* For DM355/DM365/DM6467 */ + SPI_VERSION_1, /* For DM355/DM365/DM6467*/ Above line in the patch is not required. Right. + + davinci_spi-version = pdata-version; + + davinci_spi-bitbang.flags = SPI_NO_CS | SPI_LSB_FIRST | SPI_LOOP; + if (davinci_spi-version == SPI_VERSION_2) + davinci_spi-bitbang.flags |= SPI_READY; + + dma_rx_chan = davinci_spi_get_dma_by_flag(pdev, IORESOURCE_DMA_RX_CHAN); + dma_tx_chan = davinci_spi_get_dma_by_flag(pdev, IORESOURCE_DMA_TX_CHAN); + dma_eventq = davinci_spi_get_dma_by_flag(pdev, IORESOURCE_DMA_EVENT_Q); + davinci_spi-dma_channels.dma_rx_channel = -1; + davinci_spi-dma_channels.dma_rx_sync_dev = dma_rx_chan; + davinci_spi-dma_channels.dma_tx_channel = -1; + davinci_spi-dma_channels.dma_tx_sync_dev = dma_tx_chan; + davinci_spi-dma_channels.dummy_param_slot = -1; + davinci_spi-dma_channels.eventq = dma_eventq; Can the above configurations be done only in case if DMA mode? DMA mode is selected on a per-device basis. This initialization is for the controller, so it needs to be prepared to handle DMA if a device uses it. If DMA is not required, no DMA resource need be assigned to the controller. Some way of informing the user about the mode in which the driver is working is desirable. Yes, I'll try to come up with something. ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
RE: [PATCH 3/3] davinci: spi: modify platform data for updated SPIdriver
diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index a146849..0bd9f93 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -625,12 +625,6 @@ static u64 dm365_spi0_dma_mask = DMA_BIT_MASK(32); static struct davinci_spi_platform_data dm365_spi0_pdata = { .version= SPI_VERSION_1, .num_chipselect = 2, - .clk_internal = 1, - .cs_hold= 1, - .intr_level = 0, - .poll_mode = 1,/* 0 - interrupt mode 1- polling mode */ - .c2tdelay = 0, - .t2cdelay = 0, }; static struct resource dm365_spi0_resources[] = { This patch does not contain modifications to resource structure to 'or' the IORESOURCE_DMA_RX_CHAN, IORESOURCE_DMA_TX_CHAN and IORESOURCE_DMA_EVENT_Q flags with IORESOURCE_DMA. I don't think without this modification driver will work. You are right - my mistake. I will include that in the next version. I assume you added these flags when you were testing? ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source
RE: [PATCH 0/3] davinci: spi: replace existing SPI driver
Can you please post this series to SPI development list (spi-devel-gene...@lists.sourceforge.net) CCing the maintainers David Brownell and Grant Likely? Done INTRODUCTION I have been working on a custom OMAP-L138 board that has multiple spi devices (seven) on one controller. These devices have a wide range of transfer parameters (speed, phase, polarity, internal and gpio chip selects). During my testing I found multiple errors in the davinci spi driver as a result of this complex setup. The primary issues were: 1. There is a race condition due to the SPIBUF read busy-waits for slow devices 2. I found some DMA transfer length errors under some conditions 3. The chip select code caused extra byte transfers (with no chip select active) due to writes to SPIDAT1 4. Several issues prevented using multiple SPI devices, especially the DMA code, as disucussed previously on the davinci list. This should be replicated in patch description for patch 1/3 as a record of why the original driver was removed. Will do. The fixes to these problems were not simple. I ended up making fairly large changes to the driver, and those changes are contained in these patches. The full list of changes follows. CHANGE LIST 1. davinci_spi_chipelect() now performs both activation and deactivation of chip selects. This lets spi_bitbang fully control chip select activation, as intended by the SPI API. 2. Chip select activation does not cause extra writes to the SPI bus 3. Chip select activation does not use SPIDEF for control. This change will also allow for implementation of inverted (active high) chip selects in the future. 4. Added back gpio chip select capability from the old driver 5. Fixed prescale calculation for non-integer fractions of spi clock 6. Allow specification of SPI transfer parameters on a per-device (instead of per-controller) basis 7. Allow specification of polled, interrupt-based, or DMA operation on a per-device basis 8. Allow DMA with when more than one device is connected 9. Combined pio and dma txrx_bufs functions into one since they share large parts of their functionality, and to simplify item (8). 10. Use only SPIFMT0 to allow more than 4 devices TESTING I have tested the driver using a custom SPI stress test on my OMAP-L138-based board with three devices connected. I have tested configurations with all three devices polled, all three interrupt-based, all three DMA, and a mixture. This should be replicated in patch description for patch 2/3 as a record of what the new driver provides. Will do. I have compiled with the davinci_all_defconfig, but I don't have EVMs for the other davinci platforms to test with. DM6467, DM365 and OMAP-L137 EVMs have SPI devices as well. We can help test on at least some of those. No need to wait for test results before posting to SPI list though, it can happen in parallel to the review. Ok, thanks. SUMMARY This patch solves a lot of issues that should save a lot of people time down the road. Since I posted the original patch I have had at least 5 people contact me personally to get help applying the patch because SPI was broken on their boards. I have heard back from at least 2 that the original patch worked for them. You can include an Acked-by: from those developers. This will help build the case for the new driver. I'll see if I still have the emails. ___ Davinci-linux-open-source mailing list Davinci-linux-open-source@linux.davincidsp.com http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source