Misc Tegra patches
Subsystems (3)
cover Misc Tegra patches
I have various patches for arch/arm/mach-tegra queued up in order to support the new ASoC driver. This series is all those patches except those that touch clock-related code, since I need to wait for Colin's series to land first, then drop some of my patches, and fix up any merge conflicts.
* ARM: tegra: Fix typo in TEGRA_IRQ_TO_GPIO
Simple fix. I think not previously posted.
* ARM: tegra: Prevent requeuing in-progress DMA requests
Already in {android,linux}-tegra-2.6.3[67], but not yet in mainline or for-next.
* ARM: tegra: pinmux: Expose set_func, add get_*
* ARM: tegra: Move pinmux init call
Those two are needed to support updating tegra2_clocks.c's handling of cdev[12] (see patch series I posted a while back to linux-tegra@).
I believe the first of these was previously posted, but not yet applied since it was part of a series that included a number of clock changes that needed to wait for Colin's clock changes.
The second probably hasn't been posted before, but if it has, this version also covers the trimslice board.
Stephen Warren (4):
ARM: tegra: Fix typo in TEGRA_IRQ_TO_GPIO
ARM: tegra: Prevent requeuing in-progress DMA requests
ARM: tegra: pinmux: Expose set_func, add get_*
ARM: tegra: Move pinmux init call
arch/arm/mach-tegra/board-harmony.c | 4 +- arch/arm/mach-tegra/board-trimslice.c | 4 +- arch/arm/mach-tegra/dma.c | 8 ++++ arch/arm/mach-tegra/include/mach/gpio.h | 2 +- arch/arm/mach-tegra/include/mach/pinmux.h | 9 ++++ arch/arm/mach-tegra/pinmux.c | 64 ++++++++++++++++++++++++++--- 6 files changed, 80 insertions(+), 11 deletions(-)
PATCH 1/4 ARM: tegra: Fix typo in TEGRA_IRQ_TO_GPIO
--- arch/arm/mach-tegra/include/mach/gpio.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
arch/arm/mach-tegra/include/mach/gpio.h +1 -1
@@ -31,7 +31,7 @@#define gpio_cansleep __gpio_cansleep#define TEGRA_GPIO_TO_IRQ (gpio) (INT_GPIO_BASE + (gpio)) -#define TEGRA_IRQ_TO_GPIO (irq) ((gpio) - INT_GPIO_BASE) +#define TEGRA_IRQ_TO_GPIO (irq) ((irq) - INT_GPIO_BASE)static inline int gpio_to_irq (unsigned int gpio) {
Signature · 1 line
1.7.1
PATCH 2/4 ARM: tegra: Prevent requeuing in-progress DMA requests
In reply to Stephen WarrenIf a request already in the queue is passed to tegra_dma_enqueue_req, tegra_dma_req.node->{next,prev} will end up pointing to itself instead of at tegra_dma_channel.list, which is the way a the end-of-list should be set up. When the DMA request completes and is list_del'd, the list head will still point at it, yet the node's next/prev will contain the list poison values. When the next DMA request completes, a kernel panic will occur when those poison values are dereferenced.
This makes the DMA driver more robust in the face of buggy clients.
--- arch/arm/mach-tegra/dma.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-)
arch/arm/mach-tegra/dma.c +8 -0
@@ -311,6 +311,7 @@ int tegra_dma_enqueue_req(struct tegra_dma_channel *ch, struct tegra_dma_req *req) {unsigned long irq_flags; +struct tegra_dma_req *_req;int start_dma =0 ; if (req->size > NV_DMA_MAX_TRASFER_SIZE ||
@@ -321,6 +322,13 @@ int tegra_dma_enqueue_req(struct tegra_dma_channel *ch,spin_lock_irqsave (&ch->lock, irq_flags); +list_for_each_entry (_req, &ch->list, node) { +if (req == _req) { +spin_unlock_irqrestore (&ch->lock, irq_flags); +return -EEXIST ; + } + } + req->bytes_transferred =0 ; req->status =0 ; req->buffer_status =0 ;
Signature · 1 line
1.7.1
PATCH 3/4 ARM: tegra: pinmux: Expose set_func, add get_*
In reply to Stephen WarrenExpose set_func for consistency with other set_* functions, plus other drivers can use this basic API more easily than tegra_pinmux_config_*_table.
Implement get_* to allow other drivers (e.g. clock) to initialize their state (e.g. cdev[12] parenting/enable) based on pinmux state.
--- arch/arm/mach-tegra/include/mach/pinmux.h | 9 ++++ arch/arm/mach-tegra/pinmux.c | 64 ++++++++++++++++++++++++++--- 2 files changed, 67 insertions(+), 6 deletions(-)
arch/arm/mach-tegra/include/mach/pinmux.h +9 -0
@@ -218,6 +218,15 @@ struct tegra_pingroup_desc {extern const struct tegra_pingroup_desc tegra_soc_pingroups[];extern const struct tegra_drive_pingroup_desc tegra_soc_drive_pingroups[]; +int tegra_pinmux_get_func (enum tegra_pingroup pg, +enum tegra_mux_func *func); +int tegra_pinmux_get_tristate (enum tegra_pingroup pg, +enum tegra_tristate *tristate); +int tegra_pinmux_get_pullupdown (enum tegra_pingroup pg, +enum tegra_pullupdown *pupd); + +int tegra_pinmux_set_func (enum tegra_pingroup pg, +enum tegra_mux_func func);int tegra_pinmux_set_tristate (enum tegra_pingroup pg,enum tegra_tristate tristate); int tegra_pinmux_set_pullupdown(enum tegra_pingroup pg,
arch/arm/mach-tegra/pinmux.c +58 -6
93 lines not on this page · raw message
Signature · 1 line
1.7.1
PATCH 4/4 ARM: tegra: Move pinmux init call
In reply to Stephen WarrenIn order for the clock initialization to pick up the results of the pinmux initialization (which will initialize various parameters of clocks cdev1, cdev2), the pinmux initialization must happen first. Move the pinmux init to achieve this.
--- arch/arm/mach-tegra/board-harmony.c | 4 ++-- arch/arm/mach-tegra/board-trimslice.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-)
arch/arm/mach-tegra/board-harmony.c +2 -2
@@ -104,12 +104,12 @@ static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = {static void __init tegra_harmony_init (void ) { +harmony_pinmux_init (); +tegra_common_init ();tegra_clk_init_from_table (harmony_clk_init_table); -harmony_pinmux_init (); -platform_add_devices (harmony_devices,ARRAY_SIZE (harmony_devices)); }
arch/arm/mach-tegra/board-trimslice.c +2 -2
@@ -85,12 +85,12 @@ subsys_initcall(tegra_trimslice_pci_init);static void __init tegra_trimslice_init (void ) { +trimslice_pinmux_init (); +tegra_common_init ();tegra_clk_init_from_table (trimslice_clk_init_table); -trimslice_pinmux_init (); -platform_add_devices (trimslice_devices,ARRAY_SIZE (trimslice_devices)); }
Signature · 1 line
1.7.1
Colin Cross
AppliedPATCH 2/4 ARM: tegra: Prevent requeuing in-progress DMA requests
In reply to Stephen WarrenQuoted 42 lines · Stephen Warren
If a request already in the queue is passed to
tegra_dma_enqueue_req, tegra_dma_req.node->{next,prev} will end up pointing to itself instead of at tegra_dma_channel.list, which is the way a the end-of-list should be set up. When the DMA request completes and is list_del'd, the list head will still point at it, yet the node's next/prev will contain the list poison values. When the next DMA request completes, a kernel panic will occur when those poison values are dereferenced.This makes the DMA driver more robust in the face of buggy clients.
Signed-off-by Stephen Warren <[email protected]>---
?arch/arm/mach-tegra/dma.c | ? ?8 ++++++++
?1 files changed, 8 insertions(+), 0 deletions(-)arch/arm/mach-tegra/dma.c +1
-0@@ -311,6 +311,7 @@ int tegra_dma_enqueue_req(struct tegra_dma_channel *ch, ? ? ? ?struct tegra_dma_req *req) ?{ ? ? ? ?unsigned long irq_flags; + ? ? ? struct tegra_dma_req *_req; ? ? ? ?int start_dma = 0;? ? ? ?if (
req->size>NV_DMA_MAX_TRASFER_SIZE||arch/arm/mach-tegra/dma.c +7
-1@@ -321,6 +322,13 @@ int tegra_dma_enqueue_req(struct tegra_dma_channel *ch, ? ? ? ?spin_lock_irqsave(&ch->lock, irq_flags); + ? ? ? list_for_each_entry(_req, &ch->list, node) { + ? ? ? ? ? ? ? if (req == _req) { + ? ? ? ? ? ? ? ? ? ? ? spin_unlock_irqrestore(&ch->lock, irq_flags); + ? ? ? ? ? ? ? ? ? ? ? return -EEXIST; + ? ? ? ? ? ? ? } + ? ? ? } + ? ? ? ?req->bytes_transferred = 0; ? ? ? ?req->status = 0; ? ? ? ?req->buffer_status = 0; --
Quoted 3 lines
1.7.1
Pushed to tegra for-next
PATCH 4/4 ARM: tegra: Move pinmux init call
In reply to Stephen WarrenQuoted 38 lines · Stephen Warren
In order for the clock initialization to pick up the results of the pinmux initialization (which will initialize various parameters of clocks cdev1, cdev2), the pinmux initialization must happen first. Move the pinmux init to achieve this.
Signed-off-by Stephen Warren <[email protected]>---
?arch/arm/mach-tegra/board-harmony.c ? | ? ?4 ++-- ?arch/arm/mach-tegra/board-trimslice.c | ? ?4 ++-- ?2 files changed, 4 insertions(+), 4 deletions(-)arch/arm/mach-tegra/board-harmony.c +2
-2@@ -104,12 +104,12 @@ static __initdata struct tegra_clk_init_table harmony_clk_init_table[] = { ?static void __init tegra_harmony_init(void) ?{ + ? ? ? harmony_pinmux_init(); + ? ? ? ?tegra_common_init(); ? ? ? ?tegra_clk_init_from_table(harmony_clk_init_table); - ? ? ? harmony_pinmux_init(); - ? ? ? ?platform_add_devices(harmony_devices, ARRAY_SIZE(harmony_devices)); ?}arch/arm/mach-tegra/board-trimslice.c +0
-0@@ -85,12 +85,12 @@ subsys_initcall(tegra_trimslice_pci_init); ?static void __init tegra_trimslice_init(void) ?{
arch/arm/mach-tegra/board-trimslice.c subsys_initcall(tegra_trimslice_pci_init); · line 95
Quoted 10 lines
arch/arm/mach-tegra/board-trimslice.c +2
-2+ ? ? ? trimslice_pinmux_init(); + ? ? ? ?tegra_common_init(); ? ? ? ?tegra_clk_init_from_table(trimslice_clk_init_table); - ? ? ? trimslice_pinmux_init(); - ? ? ? ?platform_add_devices(trimslice_devices, ARRAY_SIZE(trimslice_devices)); ?}
This isn't going to work any more. In order for the timer to get a reference to its clock, clocks have to be up before the system timer is initialized, so Russell added an init_early hook for clock initialization. init_machine happens much later, so the per-board pinmux init will always happen after clock init.
The calls from clk_dev1/2 init into tegra_pinmux_get_func should be fine, but they will pick up the bootloader's settings instead of the board pinmux table settings. You would need to use the pinmux tables to untristate the pins (or maybe add untristating, but not re-tristating, to the clk_enable op?), and add clk_dev1/2 entries to the clock init table to set the parent to get the correct pinmux settings.
PATCH 4/4 ARM: tegra: Move pinmux init call
Colin Cross wrote at Monday, February 21, 2011 8:22 PM:
Quoted 15 lines
Quoted 4 lines · Stephen Warren
In order for the clock initialization to pick up the results of the pinmux initialization (which will initialize various parameters of clocks cdev1, cdev2), the pinmux initialization must happen first. Move the pinmux init to achieve this.
...
Quoted 7 lines
?{
+ ? ? ?harmony_pinmux_init();
+
? ? ? ?tegra_common_init();? ? ? ?tegra_clk_init_from_table(harmony_clk_init_table);
Quoted 8 lines
Quoted 2 lines
- ? ? ?
harmony_pinmux_init();
-This isn't going to work any more. In order for the timer to get a reference to its clock, clocks have to be up before the system timer is initialized, so Russell added an
init_earlyhook for clock initialization.init_machinehappens much later, so the per-board pinmux init will always happen after clock init.
OK. Drop this patch then.
IIRC, this patch was mostly about making the state (e.g. debugfs files) match between the pinmux and clock drivers. At least initially I'll ignore this now that I know what's going on with the audio clocks, and just make audio work with the appropriate pinmux settings as you suggest.
Maybe that approach will obviate the need for my patch that adds set_parent for cdev[12], if it's done by pinmux settings instead. I'll check and see. We can think about the underlying synchronization issue between clock/pinmux later I think.
Signature · 1 line
nvpublic
Colin Cross
AppliedPATCH 1/4 ARM: tegra: Fix typo in TEGRA_IRQ_TO_GPIO
In reply to Stephen WarrenQuoted 16 lines · Stephen Warren
Signed-off-by Stephen Warren <[email protected]>---
?arch/arm/mach-tegra/include/mach/gpio.h | ? ?2 +- ?1 files changed, 1 insertions(+), 1 deletions(-)arch/arm/mach-tegra/include/mach/gpio.h +0
-0@@ -31,7 +31,7 @@?#define
gpio_cansleep? ? ? ? ?__gpio_cansleep?#define
TEGRA_GPIO_TO_IRQ(gpio)(INT_GPIO_BASE+ (gpio))arch/arm/mach-tegra/include/mach/gpio.h +1
-1-#define TEGRA_IRQ_TO_GPIO (irq) ((gpio) - INT_GPIO_BASE) +#define TEGRA_IRQ_TO_GPIO (irq) ((irq) - INT_GPIO_BASE)
Quoted 6 lines
?static inline int
gpio_to_irq(unsigned int gpio)
?{
--
1.7.1
Pushed to for-next