Re: [PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script
On Fri, Oct 10, 2008 at 10:50:29AM -0700, ext David Brownell wrote: On Friday 10 October 2008, Peter 'p2' De Schrijver wrote: +extern struct twl4030_power_data generic3430_t2scripts_data; Such extern decls should as a rule be in header files... In this case the rule is appropriate, since you've got the same decl in three different places. That's about two times more often than I'm comfortable making exceptions to such a rule ... :) Please suggest an appropriate header file. I couldn't find one and creating a header file for a single extern declaration ? Cheers, Peter. -- goa is a state of mind -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] n800: usb: fix num_eps and avoid BUG()
num_eps is 16, not 32. Signed-off-by: Felipe Balbi [EMAIL PROTECTED] --- arch/arm/mach-omap2/board-n800-usb.c |2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-omap2/board-n800-usb.c b/arch/arm/mach-omap2/board-n800-usb.c index f8df19e..fc128f2 100644 --- a/arch/arm/mach-omap2/board-n800-usb.c +++ b/arch/arm/mach-omap2/board-n800-usb.c @@ -73,7 +73,7 @@ static struct musb_hdrc_config musb_config = { .dyn_fifo = 1, .soft_con = 1, .dma= 1, - .num_eps= 32, + .num_eps= 16, .dma_channels = 7, .ram_bits = 12, .eps_bits = musb_eps, -- 1.6.0.2.307.gc427 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] HDQ Driver for OMAP2430/3430
- Original Message - From: Andrew Morton [EMAIL PROTECTED] To: Gadiyar, Anand [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; linux-omap@vger.kernel.org; [EMAIL PROTECTED] Sent: Saturday, October 11, 2008 2:08 AM Subject: Re: [PATCH 1/5] HDQ Driver for OMAP2430/3430 On Wed, 8 Oct 2008 12:46:25 +0530 Gadiyar, Anand [EMAIL PROTECTED] wrote: From: Madhusudhan Chikkature [EMAIL PROTECTED] The HDQ/1-Wire module of TI OMAP2430/3430 platforms implement the hardware protocol of the master functions of the Benchmark HDQ and the Dallas Semiconductor 1-Wire protocols. These protocols use a single wire for communication between the master (HDQ/1-Wire controller) and the slave (HDQ/1-Wire external compliant device). This patch provides the HDQ driver to suppport TI OMAP2430/3430 platforms. Every tab character in all five patches was converted to eight-spaces by your email client. Please fix the mailer and resend everything. +++ linux-2.6/drivers/w1/masters/omap_hdq.c 2008-09-26 14:28:36.0 +0530 @@ -0,0 +1,730 @@ +/* + * drivers/w1/masters/omap_hdq.c + * + * Copyright (C) 2007 Texas Instruments, Inc. + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed as is without any warranty of any + * kind, whether express or implied. + * + */ +#include linux/kernel.h +#include linux/module.h +#include linux/platform_device.h +#include linux/interrupt.h +#include linux/err.h +#include linux/clk.h +#include linux/io.h +#include asm/irq.h +#include mach/hardware.h We conventionally put a blank line between the linux/ includes and the asm/ includes. +static int omap_hdq_get(struct hdq_data *hdq_data); +static int omap_hdq_put(struct hdq_data *hdq_data); +static int omap_hdq_break(struct hdq_data *hdq_data); These three aren't strictly needed, because these functions are defined before first use. I think it's best to not declare them. +static int hdq_wait_for_flag(struct hdq_data *hdq_data, u32 offset, + u8 flag, u8 flag_set, u8 *status) +{ + int ret = 0; + unsigned long timeout = jiffies + OMAP_HDQ_TIMEOUT; + + if (flag_set == OMAP_HDQ_FLAG_CLEAR) { + /* wait for the flag clear */ + while (((*status = hdq_reg_in(hdq_data, offset)) flag) +time_before(jiffies, timeout)) { + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); Use schedule_timeout_uninterruptible(1) + } + if (*status flag) + ret = -ETIMEDOUT; + } else if (flag_set == OMAP_HDQ_FLAG_SET) { + /* wait for the flag set */ + while (!((*status = hdq_reg_in(hdq_data, offset)) flag) +time_before(jiffies, timeout)) { + set_current_state(TASK_UNINTERRUPTIBLE); + schedule_timeout(1); elsewhere.. + } + if (!(*status flag)) + ret = -ETIMEDOUT; + } else + return -EINVAL; + + return ret; +} + +/* write out a byte and fill *status with HDQ_INT_STATUS */ +static int hdq_write_byte(struct hdq_data *hdq_data, u8 val, u8 *status) +{ + int ret; + u8 tmp_status; + unsigned long irqflags; + + *status = 0; + + spin_lock_irqsave(hdq_data-hdq_spinlock, irqflags); + /* clear interrupt flags via a dummy read */ + hdq_reg_in(hdq_data, OMAP_HDQ_INT_STATUS); + /* ISR loads it with new INT_STATUS */ + hdq_data-hdq_irqstatus = 0; + spin_unlock_irqrestore(hdq_data-hdq_spinlock, irqflags); + + hdq_reg_out(hdq_data, OMAP_HDQ_TX_DATA, val); + + /* set the GO bit */ + hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, OMAP_HDQ_CTRL_STATUS_GO, + OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_GO); + /* wait for the TXCOMPLETE bit */ + ret = wait_event_interruptible_timeout(hdq_wait_queue, + hdq_data-hdq_irqstatus, OMAP_HDQ_TIMEOUT); + if (ret 0) { + dev_dbg(hdq_data-dev, wait interrupted); + return -EINTR; + } Is this desirable? The user hits ^C and the driver bails out? I assume so, but was this tested? Andrew, What is the test scenario you mean here? A user hitting ^C when the driver is waiting for the TXCOMPLETE bit? + spin_lock_irqsave(hdq_data-hdq_spinlock, irqflags); + *status = hdq_data-hdq_irqstatus; + spin_unlock_irqrestore(hdq_data-hdq_spinlock, irqflags); It's unusual to put a lock around a single atomic move instruction. + /* check irqstatus */ + if (!(*status OMAP_HDQ_INT_STATUS_TXCOMPLETE)) { + dev_dbg(hdq_data-dev, timeout waiting for + TXCOMPLETE/RXCOMPLETE,
Re: git pull request for minimal omap3 support one more time
On Fri, Oct 10, 2008 at 02:35:34PM +0300, Tony Lindgren wrote: * Tony Lindgren [EMAIL PROTECTED] [081010 12:41]: * Tony Lindgren [EMAIL PROTECTED] [081010 12:15]: * Russell King - ARM Linux [EMAIL PROTECTED] [081010 11:42]: On Thu, Oct 09, 2008 at 06:17:25PM +0300, Tony Lindgren wrote: Sure, I'll post a minimal LDP patch separately tomorrow. I don't have an LDP so I can't verify it boots though. Unfortunately, Linus has been unpredictable, and released 2.6.27 last night, rather than the usual one week after -rc9. What this means is that the merge window is now open, and I shouldn't be accepting anything else into my kernel tree. However, if you can get LDP in by this evening, I'll pull it into the tree. That will be the final devel code merged into my tree for 2.6.28. Sure. Here's the minimal board patch for LDP with it's defconfig in the following mail. Also added to the omap3-upstream queue. Here's the defconfig. And here's the updated pull request for you with the LDP patches added. I also changed the title of the Overo patches to say OMAP3 instead of OMAP2 for consistency. Note that this will also pull the already posted omap2-upstream as omap3-upstream is based on that. There's something wrong with one of the sets I've pulled from you: arch/arm/mach-omap2/mcbsp.c:253: error: ‘INT_24XX_MCBSP3_IRQ_RX’ undeclared here (not in a function) arch/arm/mach-omap2/mcbsp.c:254: error: ‘INT_24XX_MCBSP3_IRQ_TX’ undeclared here (not in a function) arch/arm/mach-omap2/mcbsp.c:262: error: ‘INT_24XX_MCBSP4_IRQ_RX’ undeclared here (not in a function) arch/arm/mach-omap2/mcbsp.c:263: error: ‘INT_24XX_MCBSP4_IRQ_TX’ undeclared here (not in a function) arch/arm/mach-omap2/mcbsp.c:271: error: ‘INT_24XX_MCBSP5_IRQ_RX’ undeclared here (not in a function) arch/arm/mach-omap2/mcbsp.c:272: error: ‘INT_24XX_MCBSP5_IRQ_TX’ undeclared here (not in a function) Please take a look and resolve ASAP. Thanks. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] HDQ Driver for OMAP2430/3430
Hi. On Mon, Oct 13, 2008 at 06:55:43PM +0530, Madhusudhan Chikkature ([EMAIL PROTECTED]) wrote: +static int hdq_write_byte(struct hdq_data *hdq_data, u8 val, u8 *status) +{ + int ret; + u8 tmp_status; + unsigned long irqflags; + + *status = 0; + + spin_lock_irqsave(hdq_data-hdq_spinlock, irqflags); + /* clear interrupt flags via a dummy read */ + hdq_reg_in(hdq_data, OMAP_HDQ_INT_STATUS); + /* ISR loads it with new INT_STATUS */ + hdq_data-hdq_irqstatus = 0; + spin_unlock_irqrestore(hdq_data-hdq_spinlock, irqflags); + + hdq_reg_out(hdq_data, OMAP_HDQ_TX_DATA, val); + + /* set the GO bit */ + hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, OMAP_HDQ_CTRL_STATUS_GO, + OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_GO); + /* wait for the TXCOMPLETE bit */ + ret = wait_event_interruptible_timeout(hdq_wait_queue, + hdq_data-hdq_irqstatus, OMAP_HDQ_TIMEOUT); + if (ret 0) { + dev_dbg(hdq_data-dev, wait interrupted); + return -EINTR; + } Is this desirable? The user hits ^C and the driver bails out? I assume so, but was this tested? Andrew, What is the test scenario you mean here? A user hitting ^C when the driver is waiting for the TXCOMPLETE bit? Just plain return looks suspicious, is there some kind of a race between calling code (which for example frees hdq_data) and the path, which sets the bit and wakes up this thread? -- Evgeniy Polyakov -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 0/7] Integrate the twl4030 power code into new twl4030 mfd
This patchset integrates the twl4030 power code into the new twl4030 mfd framework. The scripts will be moved to the board specific data. Peter 'p2' De Schrijver (7): Remove existing twl4030 power script code. Add defines and data types for twl4030. Twl4030 power code updated for new twl4030 core Hook twl4030 power code into twl4030 core. 3430sdp and ldp use custom twl4030 power scripts. Generic twl4030 power script for 3430 based boards. omap3 evm, beagle and overo use the generic twl4030 script arch/arm/mach-omap2/Makefile |9 +- arch/arm/mach-omap2/board-3430sdp.c | 84 ++ arch/arm/mach-omap2/board-ldp.c | 84 ++ arch/arm/mach-omap2/board-omap3beagle.c |4 +- arch/arm/mach-omap2/board-omap3evm.c |4 +- arch/arm/mach-omap2/board-overo.c |4 +- arch/arm/mach-omap2/twl4030-generic-scripts.c | 78 ++ arch/arm/mach-omap2/twl4030-generic-scripts.h |8 + drivers/i2c/chips/Makefile|2 +- drivers/i2c/chips/twl4030-power.c | 343 - drivers/mfd/Kconfig |7 + drivers/mfd/Makefile |1 + drivers/mfd/twl4030-core.c| 11 + drivers/mfd/twl4030-power.c | 270 +++ include/linux/i2c/twl4030.h | 64 + 15 files changed, 620 insertions(+), 353 deletions(-) create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.c create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.h delete mode 100644 drivers/i2c/chips/twl4030-power.c create mode 100644 drivers/mfd/twl4030-power.c -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 2/7] Add defines and data types for twl4030.
This patch adds a bunch of data types and defines to handle the twl4030 power sequence scripts. Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED] --- include/linux/i2c/twl4030.h | 64 +++ 1 files changed, 64 insertions(+), 0 deletions(-) diff --git a/include/linux/i2c/twl4030.h b/include/linux/i2c/twl4030.h index cdb4531..7dc4ee1 100644 --- a/include/linux/i2c/twl4030.h +++ b/include/linux/i2c/twl4030.h @@ -264,6 +264,69 @@ struct twl4030_usb_data { enum twl4030_usb_mode usb_mode; }; +struct twl4030_ins { + u16 pmb_message; + u8 delay; +}; + +struct twl4030_script { + struct twl4030_ins *script; + unsigned size; + u8 flags; +}; +#define TRITON_WRST_SCRIPT (10) +#define TRITON_WAKEUP12_SCRIPT (11) +#define TRITON_WAKEUP3_SCRIPT (12) +#define TRITON_SLEEP_SCRIPT(13) + +struct twl4030_power_data { + struct twl4030_script **scripts; + unsigned size; +}; + +/* Power bus message definitions */ + +#define DEV_GRP_NULL 0x0 +#define DEV_GRP_P1 0x1 +#define DEV_GRP_P2 0x2 +#define DEV_GRP_P3 0x4 + +#define RES_GRP_RES0x0 +#define RES_GRP_PP 0x1 +#define RES_GRP_RC 0x2 +#define RES_GRP_PP_RC 0x3 +#define RES_GRP_PR 0x4 +#define RES_GRP_PP_PR 0x5 +#define RES_GRP_RC_PR 0x6 +#define RES_GRP_ALL0x7 + +#define RES_TYPE2_R0 0x0 + +#define RES_TYPE_ALL 0x7 + +#define RES_STATE_WRST 0xF +#define RES_STATE_ACTIVE 0xE +#define RES_STATE_SLEEP0x8 +#define RES_STATE_OFF 0x0 + +/* +* Power Bus Message Format +* +* Broadcast Message (16 Bits) +* DEV_GRP[15:13] MT[12] RES_GRP[11:9] RES_TYPE2[8:7] RES_TYPE[6:4] +* RES_STATE[3:0] +* +* Singular Message (16 Bits) +* DEV_GRP[15:13] MT[12] RES_ID[11:4] RES_STATE[3:0] +* +*/ + +#define MSG_BROADCAST(devgrp, grp, type, type2, state) \ + (devgrp 13 | 1 12 | grp 9 | type2 7 | type 4 | state) + +#define MSG_SINGULAR(devgrp, id, state) \ + (devgrp 13 | 0 12 | id 4 | state) + struct twl4030_platform_data { unsignedirq_base, irq_end; struct twl4030_bci_platform_data*bci; @@ -271,6 +334,7 @@ struct twl4030_platform_data { struct twl4030_madc_platform_data *madc; struct twl4030_keypad_data *keypad; struct twl4030_usb_data *usb; + struct twl4030_power_data *power; /* REVISIT more to come ... _nothing_ should be hard-wired */ }; -- 1.5.6.3 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 3/7] Twl4030 power code updated for new twl4030 core
This patch adds the twl4030 power handling. It downloads the scripts provided by the board configuration to the twl4030 and configures the chip to call the relevant script for each event (processor group 1 and 2 sleep, processor group 3 sleep, wakeup or warm reset). Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED] --- drivers/mfd/twl4030-power.c | 270 +++ 1 files changed, 270 insertions(+), 0 deletions(-) create mode 100644 drivers/mfd/twl4030-power.c diff --git a/drivers/mfd/twl4030-power.c b/drivers/mfd/twl4030-power.c new file mode 100644 index 000..d9d1655 --- /dev/null +++ b/drivers/mfd/twl4030-power.c @@ -0,0 +1,270 @@ +/* + * linux/drivers/i2c/chips/twl4030-power.c + * + * Handle TWL4030 Power initialization + * + * Copyright (C) 2008 Nokia Corporation + * Copyright (C) 2006 Texas Instruments, Inc + * + * Written by Kalle Jokiniemi + * Peter De Schrijver [EMAIL PROTECTED] + * + * This file is subject to the terms and conditions of the GNU General + * Public License. See the file COPYING in the main directory of this + * archive for more details. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include linux/module.h +#include linux/pm.h +#include linux/i2c/twl4030.h +#include linux/platform_device.h + +#include asm/mach-types.h + +static u8 triton_next_free_address = 0x2b; + +#define PWR_P1_SW_EVENTS 0x10 +#define PWR_DEVOFF (10) + +#define PHY_TO_OFF_PM_MASTER(p)(p - 0x36) +#define PHY_TO_OFF_PM_RECEIVER(p) (p - 0x5b) + +/* resource - hfclk */ +#define R_HFCLKOUT_DEV_GRP PHY_TO_OFF_PM_RECEIVER(0xe6) + +/* PM events */ +#define R_P1_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x46) +#define R_P2_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x47) +#define R_P3_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x48) +#define R_CFG_P1_TRANSITIONPHY_TO_OFF_PM_MASTER(0x36) +#define R_CFG_P2_TRANSITIONPHY_TO_OFF_PM_MASTER(0x37) +#define R_CFG_P3_TRANSITIONPHY_TO_OFF_PM_MASTER(0x38) + +#define LVL_WAKEUP 0x08 + +#define ENABLE_WARMRESET (14) + +#define END_OF_SCRIPT 0x3f + +#define R_SEQ_ADD_A2S PHY_TO_OFF_PM_MASTER(0x55) +#define R_SEQ_ADD_SA12 PHY_TO_OFF_PM_MASTER(0x56) +#defineR_SEQ_ADD_S2A3 PHY_TO_OFF_PM_MASTER(0x57) +#defineR_SEQ_ADD_WARM PHY_TO_OFF_PM_MASTER(0x58) +#define R_MEMORY_ADDRESS PHY_TO_OFF_PM_MASTER(0x59) +#define R_MEMORY_DATA PHY_TO_OFF_PM_MASTER(0x5a) + +#define R_PROTECT_KEY 0x0E +#define KEY_1 0xC0 +#define KEY_2 0x0C + +static int __init twl4030_write_script_byte(u8 address, u8 byte) +{ + int err; + + err = twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, + R_MEMORY_ADDRESS); + err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, byte, + R_MEMORY_DATA); + + return err; +} + +static int __init twl4030_write_script_ins(u8 address, u16 pmb_message, + u8 delay, u8 next) +{ + int err = 0; + + address *= 4; + err |= twl4030_write_script_byte(address++, pmb_message 8); + err |= twl4030_write_script_byte(address++, pmb_message 0xff); + err |= twl4030_write_script_byte(address++, delay); + err |= twl4030_write_script_byte(address++, next); + + return err; +} + +static int __init twl4030_write_script(u8 address, struct twl4030_ins *script, + int len) +{ + int err = 0; + + for (; len; len--, address++, script++) { + if (len == 1) + err |= twl4030_write_script_ins(address, + script-pmb_message, + script-delay, + END_OF_SCRIPT); + else + err |= twl4030_write_script_ins(address, + script-pmb_message, + script-delay, + address + 1); + } + + return err; +} + +static int __init config_wakeup3_sequence(u8 address) +{ + + int err = 0; + + /* Set SLEEP to ACTIVE SEQ address for P3 */ + err |= twl4030_i2c_write_u8(TWL4030_MODULE_PM_MASTER, address, + R_SEQ_ADD_S2A3); + +
[PATCH 5/7] 3430sdp and ldp use custom twl4030 power scripts.
The TI 3430dsp and ldp boards have a custom power script to handle sleep and off modes. Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED] --- arch/arm/mach-omap2/board-3430sdp.c | 84 +++ arch/arm/mach-omap2/board-ldp.c | 84 +++ 2 files changed, 168 insertions(+), 0 deletions(-) diff --git a/arch/arm/mach-omap2/board-3430sdp.c b/arch/arm/mach-omap2/board-3430sdp.c index 56f28ae..bb591bb 100644 --- a/arch/arm/mach-omap2/board-3430sdp.c +++ b/arch/arm/mach-omap2/board-3430sdp.c @@ -47,6 +47,8 @@ #include sdram-qimonda-hyb18m512160af-6.h +#define CONFIG_DISABLE_HFCLK 1 + #defineSDP3430_SMC91X_CS 3 #define ENABLE_VAUX3_DEDICATED 0x03 @@ -329,6 +331,87 @@ static struct twl4030_madc_platform_data sdp3430_madc_data = { .irq_line = 1, }; + +static struct twl4030_ins __initdata sleep_on_seq[] = { +/* + * Turn off VDD1 and VDD2. + */ + {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4}, + {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2}, +#ifdef CONFIG_DISABLE_HFCLK +/* + * And also turn off the OMAP3 PLLs and the sysclk output. + */ + {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3}, + {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 3}, +#endif +}; + +static struct twl4030_script sleep_on_script __initdata = { + .script = sleep_on_seq, + .size = ARRAY_SIZE(sleep_on_seq), + .flags = TRITON_SLEEP_SCRIPT, +}; + +static struct twl4030_ins wakeup_seq[] __initdata = { +#ifndef CONFIG_DISABLE_HFCLK +/* + * Wakeup VDD1 and VDD2. + */ + {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 4}, + {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 2}, +#else +/* + * Reenable the OMAP3 PLLs. + * Wakeup VDD1 and VDD2. + * Reenable sysclk output. + */ + {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_ACTIVE), 0x30}, + {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_ACTIVE), 0x30}, + {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_ACTIVE), 0x37}, + {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 3}, +#endif /* #ifndef CONFIG_DISABLE_HFCLK */ +}; + +static struct twl4030_script wakeup_script __initdata = { + .script = wakeup_seq, + .size = ARRAY_SIZE(wakeup_seq), + .flags = TRITON_WAKEUP12_SCRIPT | TRITON_WAKEUP3_SCRIPT, +}; + +static struct twl4030_ins wrst_seq[] __initdata = { +/* + * Reset twl4030. + * Reset VDD1 regulator. + * Reset VDD2 regulator. + * Reset VPLL1 regulator. + * Enable sysclk output. + * Reenable twl4030. + */ + {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_OFF), 2}, + {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_WRST), 15}, + {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_WRST), 15}, + {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_WRST), 0x60}, + {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_ACTIVE), 2}, + {MSG_SINGULAR(DEV_GRP_NULL, 0x1b, RES_STATE_ACTIVE), 2}, +}; +static struct twl4030_script wrst_script __initdata = { + .script = wrst_seq, + .size = ARRAY_SIZE(wakeup_seq), + .flags = TRITON_WRST_SCRIPT, +}; + +static struct twl4030_script *twl4030_scripts[] __initdata = { + sleep_on_script, + wakeup_script, + wrst_script, +}; + +static struct twl4030_power_data sdp3430_t2scripts_data __initdata = { + .scripts= twl4030_scripts, + .size = ARRAY_SIZE(twl4030_scripts), +}; + static struct twl4030_platform_data sdp3430_twldata = { .irq_base = TWL4030_IRQ_BASE, .irq_end= TWL4030_IRQ_END, @@ -338,6 +421,7 @@ static struct twl4030_platform_data sdp3430_twldata = { .gpio = sdp3430_gpio_data, .madc = sdp3430_madc_data, .keypad = sdp3430_kp_data, + .power = sdp3430_t2scripts_data, .usb= sdp3430_usb_data, }; diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c index 92710c3..d4d4e90 100644 --- a/arch/arm/mach-omap2/board-ldp.c +++ b/arch/arm/mach-omap2/board-ldp.c @@ -41,6 +41,8 @@ #include asm/delay.h #include mach/control.h +#define CONFIG_DISABLE_HFCLK 1 + #define ENABLE_VAUX1_DEDICATED 0x03 #define ENABLE_VAUX1_DEV_GRP 0x20 @@ -195,6 +197,87 @@ static int ldp_batt_table[] = { 4040, 3910, 3790, 3670, 3550 }; +static struct twl4030_ins __initdata sleep_on_seq[] = { +/* + * Turn off VDD1 and VDD2. + */ + {MSG_SINGULAR(DEV_GRP_P1, 0xf, RES_STATE_OFF), 4}, + {MSG_SINGULAR(DEV_GRP_P1, 0x10, RES_STATE_OFF), 2}, +#ifdef CONFIG_DISABLE_HFCLK +/* + * And also turn off the OMAP3 PLLs and the sysclk output. + */ + {MSG_SINGULAR(DEV_GRP_P1, 0x7, RES_STATE_OFF), 3}, + {MSG_SINGULAR(DEV_GRP_P1, 0x19, RES_STATE_OFF), 3}, +#endif +}; + +static struct twl4030_script sleep_on_script __initdata = { + .script = sleep_on_seq, + .size = ARRAY_SIZE(sleep_on_seq), + .flags = TRITON_SLEEP_SCRIPT, +}; + +static struct twl4030_ins
[PATCH 7/7] omap3 evm, beagle and overo use the generic twl4030 script
Make omap3 evm, beagle and overo use the generic twl4030 script. Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED] --- arch/arm/mach-omap2/Makefile|9 ++--- arch/arm/mach-omap2/board-omap3beagle.c |4 ++-- arch/arm/mach-omap2/board-omap3evm.c|4 ++-- arch/arm/mach-omap2/board-overo.c |4 ++-- 4 files changed, 12 insertions(+), 9 deletions(-) diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile index 33de217..ed0cd7a 100644 --- a/arch/arm/mach-omap2/Makefile +++ b/arch/arm/mach-omap2/Makefile @@ -58,10 +58,12 @@ obj-$(CONFIG_MACH_OMAP_3430SDP) += board-3430sdp.o \ obj-$(CONFIG_MACH_OMAP3EVM)+= board-omap3evm.o \ hsmmc.o \ usb-musb.o usb-ehci.o \ - board-omap3evm-flash.o + board-omap3evm-flash.o \ + twl4030-generic-scripts.o obj-$(CONFIG_MACH_OMAP3_BEAGLE)+= board-omap3beagle.o \ usb-musb.o usb-ehci.o \ - hsmmc.o + hsmmc.o \ + twl4030-generic-scripts.o obj-$(CONFIG_MACH_OMAP_LDP)+= board-ldp.o \ hsmmc.o \ usb-musb.o @@ -77,7 +79,8 @@ obj-$(CONFIG_MACH_NOKIA_N810) += board-n810.o obj-$(CONFIG_MACH_OVERO) += board-overo.o \ hsmmc.o \ usb-musb.o \ - usb-ehci.o + usb-ehci.o \ + twl4030-generic-scripts.o # TUSB 6010 chips obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c index 19702c7..cc9506b 100644 --- a/arch/arm/mach-omap2/board-omap3beagle.c +++ b/arch/arm/mach-omap2/board-omap3beagle.c @@ -24,8 +24,6 @@ #include linux/input.h #include linux/gpio_keys.h -#include linux/i2c/twl4030.h - #include linux/mtd/mtd.h #include linux/mtd/partitions.h #include linux/mtd/nand.h @@ -45,6 +43,7 @@ #include mach/nand.h #include mach/mux.h +#include twl4030-generic-scripts.h #define GPMC_CS0_BASE 0x60 #define GPMC_CS_SIZE 0x30 @@ -149,6 +148,7 @@ static struct twl4030_platform_data beagle_twldata = { /* platform_data for children goes here */ .usb= beagle_usb_data, .gpio = beagle_gpio_data, + .power = generic3430_t2scripts_data, }; static struct i2c_board_info __initdata beagle_i2c_boardinfo[] = { diff --git a/arch/arm/mach-omap2/board-omap3evm.c b/arch/arm/mach-omap2/board-omap3evm.c index 3538067..a72772f 100644 --- a/arch/arm/mach-omap2/board-omap3evm.c +++ b/arch/arm/mach-omap2/board-omap3evm.c @@ -20,8 +20,6 @@ #include linux/clk.h #include linux/input.h -#include linux/i2c/twl4030.h - #include linux/spi/spi.h #include linux/spi/ads7846.h #include linux/i2c/twl4030.h @@ -41,6 +39,7 @@ #include mach/mcspi.h #include sdram-micron-mt46h32m32lf-6.h +#include twl4030-generic-scripts.h static struct resource omap3evm_smc911x_resources[] = { [0] = { @@ -139,6 +138,7 @@ static struct twl4030_platform_data omap3evm_twldata = { .keypad = omap3evm_kp_data, .madc = omap3evm_madc_data, .usb= omap3evm_usb_data, + .power = generic3430_t2scripts_data, .gpio = omap3evm_gpio_data, }; diff --git a/arch/arm/mach-omap2/board-overo.c b/arch/arm/mach-omap2/board-overo.c index 4e2781a..b0e5cec 100644 --- a/arch/arm/mach-omap2/board-overo.c +++ b/arch/arm/mach-omap2/board-overo.c @@ -27,8 +27,6 @@ #include linux/kernel.h #include linux/platform_device.h -#include linux/i2c/twl4030.h - #include linux/mtd/mtd.h #include linux/mtd/nand.h #include linux/mtd/partitions.h @@ -50,6 +48,7 @@ #include mach/usb-musb.h #include sdram-micron-mt46h32m32lf-6.h +#include twl4030-generic-scripts.h #define NAND_BLOCK_SIZE SZ_128K #define GPMC_CS0_BASE 0x60 @@ -160,6 +159,7 @@ static struct twl4030_platform_data overo_twldata = { .irq_end= TWL4030_IRQ_END, .gpio = overo_gpio_data, .usb= overo_usb_data, + .power = generic3430_t2scripts_data, }; static struct i2c_board_info __initdata overo_i2c_boardinfo[] = { -- 1.5.6.3 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 4/7] Hook twl4030 power code into twl4030 core.
This patch makes twl4030 core call the power code in case the scripts are present in the platform data. Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED] --- drivers/mfd/Kconfig|7 +++ drivers/mfd/Makefile |1 + drivers/mfd/twl4030-core.c | 11 +++ 3 files changed, 19 insertions(+), 0 deletions(-) diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index e643f6b..f3a5f63 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -64,6 +64,13 @@ config TWL4030_CORE high speed USB OTG transceiver, an audio codec (on most versions) and many other features. +config TWL4030_POWER + bool Support power sequencing scripts on TWL4030/TPS659x0 + depends on TWL4030_CORE=y + help + Say yes here if you want to use the power management features of + the TWL4030/TPS659x0. + config MFD_TMIO bool default n diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 5650e7b..08c5dfe 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -13,6 +13,7 @@ obj-$(CONFIG_MFD_TC6387XB)+= tc6387xb.o obj-$(CONFIG_MFD_TC6393XB) += tc6393xb.o obj-$(CONFIG_TWL4030_CORE) += twl4030-core.o +obj-$(CONFIG_TWL4030_POWER)+= twl4030-power.o obj-$(CONFIG_MFD_CORE) += mfd-core.o diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c index fd9a016..7a5c9d0 100644 --- a/drivers/mfd/twl4030-core.c +++ b/drivers/mfd/twl4030-core.c @@ -81,6 +81,12 @@ #define twl_has_madc() false #endif +#ifdef CONFIG_TWL4030_POWER +#define twl_has_power()true +#else +#define twl_has_power()false +#endif + #if defined(CONFIG_RTC_DRV_TWL4030) || defined(CONFIG_RTC_DRV_TWL4030_MODULE) #define twl_has_rtc() true #else @@ -106,6 +112,8 @@ static inline void activate_irq(int irq) #endif } +extern void twl4030_power_init(struct twl4030_power_data *triton2_scripts); + /* Primary Interrupt Handler on TWL4030 Registers */ /* Register Definitions */ @@ -794,6 +802,9 @@ static int add_children(struct twl4030_platform_data *pdata) } } + if (twl_has_power() pdata-power) + twl4030_power_init(pdata-power); + if (twl_has_rtc()) { twl = twl4030_modules[3]; -- 1.5.6.3 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 6/7] Generic twl4030 power script for 3430 based boards.
This is a generic twl4030 power script for 3430 based boards. It handles sleep and wakeup events. In case of a sleep event it will first put the Reset and Control (RC) resources to sleep and then put the voltage regulators to sleep. In case of a wakeup event, the system clock will be started first, then the voltage regulators will be woken up and finally the RC resources will be woken up. Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED] --- arch/arm/mach-omap2/twl4030-generic-scripts.c | 78 + arch/arm/mach-omap2/twl4030-generic-scripts.h |8 +++ 2 files changed, 86 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.c create mode 100644 arch/arm/mach-omap2/twl4030-generic-scripts.h diff --git a/arch/arm/mach-omap2/twl4030-generic-scripts.c b/arch/arm/mach-omap2/twl4030-generic-scripts.c new file mode 100644 index 000..f41c9ef --- /dev/null +++ b/arch/arm/mach-omap2/twl4030-generic-scripts.c @@ -0,0 +1,78 @@ +/* + * arch/arm/mach-omap2/twl4030-generic-scripts.c + * + * Generic power control scripts for TWL4030 + * + * Copyright (C) 2008 Nokia Corporation + * Copyright (C) 2006 Texas Instruments, Inc + * + * Written by Kalle Jokiniemi + * Peter De Schrijver [EMAIL PROTECTED] + * + * This file is subject to the terms and conditions of the GNU General + * Public License. See the file COPYING in the main directory of this + * archive for more details. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#include linux/kernel.h +#include linux/device.h +#include linux/init.h +#include linux/i2c/twl4030.h + +/* + * This script instructs twl4030 to first put the Reset and Control (RC) + * resources to sleep and then all the other resources. + */ + +static struct twl4030_ins sleep_on_seq[] __initdata = { + {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_RC, RES_TYPE_ALL, RES_TYPE2_R0, + RES_STATE_SLEEP), 4}, + {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, RES_TYPE2_R0, + RES_STATE_SLEEP), 4}, +}; + +static struct twl4030_script sleep_on_script __initdata = { + .script = sleep_on_seq, + .size = ARRAY_SIZE(sleep_on_seq), + .flags = TRITON_SLEEP_SCRIPT, +}; + +/* + * This script instructs twl4030 to first enable CLKEN, then wakeup the + * regulators and then all other resources. + */ + +static struct twl4030_ins wakeup_seq[] __initdata = { + {MSG_SINGULAR(DEV_GRP_NULL, 0x17, RES_STATE_ACTIVE), 0x30}, + {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_PP_PR, RES_TYPE_ALL, RES_TYPE2_R0, + RES_STATE_ACTIVE), 0x37}, + {MSG_BROADCAST(DEV_GRP_NULL, RES_GRP_ALL, RES_TYPE_ALL, RES_TYPE2_R0, + RES_STATE_ACTIVE), 0x2}, +}; + +static struct twl4030_script wakeup_script __initdata = { + .script = wakeup_seq, + .size = ARRAY_SIZE(wakeup_seq), + .flags = TRITON_WAKEUP12_SCRIPT | TRITON_WAKEUP3_SCRIPT, +}; + +static struct twl4030_script *twl4030_scripts[] __initdata = { + sleep_on_script, + wakeup_script, +}; + +struct twl4030_power_data generic3430_t2scripts_data __initdata = { + .scripts= twl4030_scripts, + .size = ARRAY_SIZE(twl4030_scripts), +}; + + diff --git a/arch/arm/mach-omap2/twl4030-generic-scripts.h b/arch/arm/mach-omap2/twl4030-generic-scripts.h new file mode 100644 index 000..64d8d3f --- /dev/null +++ b/arch/arm/mach-omap2/twl4030-generic-scripts.h @@ -0,0 +1,8 @@ +#ifndef __TWL4030_GENERIC_SCRIPTS_H +#define __TWL4030_GENERIC_SCRIPTS_H + +#include linux/i2c/twl4030.h + +extern struct twl4030_power_data generic3430_t2scripts_data; + +#endif -- 1.5.6.3 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH 1/7] Remove existing twl4030 power script code.
First we remove the existing twl4030 power sequencer code. Signed-off-by: Peter 'p2' De Schrijver [EMAIL PROTECTED] --- drivers/i2c/chips/Makefile|2 +- drivers/i2c/chips/twl4030-power.c | 343 - 2 files changed, 1 insertions(+), 344 deletions(-) delete mode 100644 drivers/i2c/chips/twl4030-power.c diff --git a/drivers/i2c/chips/Makefile b/drivers/i2c/chips/Makefile index ba41a57..7e0fdfa 100644 --- a/drivers/i2c/chips/Makefile +++ b/drivers/i2c/chips/Makefile @@ -24,7 +24,7 @@ obj-$(CONFIG_GPIOEXPANDER_OMAP) += gpio_expander_omap.o obj-$(CONFIG_MENELAUS) += menelaus.o obj-$(CONFIG_SENSORS_TSL2550) += tsl2550.o obj-$(CONFIG_SENSORS_TSL2563) += tsl2563.o -obj-$(CONFIG_TWL4030_CORE) += twl4030-pwrirq.o twl4030-power.o +obj-$(CONFIG_TWL4030_CORE) += twl4030-pwrirq.o obj-$(CONFIG_TWL4030_USB) += twl4030-usb.o obj-$(CONFIG_TWL4030_POWEROFF) += twl4030-poweroff.o obj-$(CONFIG_TWL4030_PWRBUTTON)+= twl4030-pwrbutton.o diff --git a/drivers/i2c/chips/twl4030-power.c b/drivers/i2c/chips/twl4030-power.c deleted file mode 100644 index cb325b0..000 --- a/drivers/i2c/chips/twl4030-power.c +++ /dev/null @@ -1,343 +0,0 @@ -/* - * linux/drivers/i2c/chips/twl4030-power.c - * - * Handle TWL4030 Power initialization - * - * Copyright (C) 2008 Nokia Corporation - * Copyright (C) 2006 Texas Instruments, Inc - * - * Written by Kalle Jokiniemi - * Peter De Schrijver [EMAIL PROTECTED] - * - * This file is subject to the terms and conditions of the GNU General - * Public License. See the file COPYING in the main directory of this - * archive for more details. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include linux/module.h -#include linux/pm.h -#include linux/i2c/twl4030.h - -#include asm/mach-types.h - -#define PWR_P1_SW_EVENTS 0x10 -#define PWR_DEVOFF (10) - -#define PHY_TO_OFF_PM_MASTER(p)(p - 0x36) -#define PHY_TO_OFF_PM_RECIEVER(p) (p - 0x5b) - -/* resource - hfclk */ -#define R_HFCLKOUT_DEV_GRP PHY_TO_OFF_PM_RECIEVER(0xe6) - -/* PM events */ -#define R_P1_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x46) -#define R_P2_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x47) -#define R_P3_SW_EVENTS PHY_TO_OFF_PM_MASTER(0x48) -#define R_CFG_P1_TRANSITIONPHY_TO_OFF_PM_MASTER(0x36) -#define R_CFG_P2_TRANSITIONPHY_TO_OFF_PM_MASTER(0x37) -#define R_CFG_P3_TRANSITIONPHY_TO_OFF_PM_MASTER(0x38) - -#define LVL_WAKEUP 0x08 - -#define ENABLE_WARMRESET (14) - -/* sequence script */ - -#define END_OF_SCRIPT 0x3f - -#define R_SEQ_ADD_A2S PHY_TO_OFF_PM_MASTER(0x55) -#define R_SEQ_ADD_SA12 PHY_TO_OFF_PM_MASTER(0x56) -#defineR_SEQ_ADD_S2A3 PHY_TO_OFF_PM_MASTER(0x57) -#defineR_SEQ_ADD_WARM PHY_TO_OFF_PM_MASTER(0x58) -#define R_MEMORY_ADDRESS PHY_TO_OFF_PM_MASTER(0x59) -#define R_MEMORY_DATA PHY_TO_OFF_PM_MASTER(0x5a) - -/* Power bus message definitions */ - -#define DEV_GRP_NULL 0x0 -#define DEV_GRP_P1 0x1 -#define DEV_GRP_P2 0x2 -#define DEV_GRP_P3 0x4 - -#define RES_GRP_RES0x0 -#define RES_GRP_PP 0x1 -#define RES_GRP_RC 0x2 -#define RES_GRP_PP_RC 0x3 -#define RES_GRP_PR 0x4 -#define RES_GRP_PP_PR 0x5 -#define RES_GRP_RC_PR 0x6 -#define RES_GRP_ALL0x7 - -#define RES_TYPE2_R0 0x0 - -#define RES_TYPE_ALL 0x7 - -#define RES_STATE_WRST 0xF -#define RES_STATE_ACTIVE 0xE -#define RES_STATE_SLEEP0x8 -#define RES_STATE_OFF 0x0 - -/* -* Power Bus Message Format -* -* Broadcast Message (16 Bits) -* DEV_GRP[15:13] MT[12] RES_GRP[11:9] RES_TYPE2[8:7] RES_TYPE[6:4] -* RES_STATE[3:0] -* -* Singular Message (16 Bits) -* DEV_GRP[15:13] MT[12] RES_ID[11:4] RES_STATE[3:0] -* -*/ - -#define MSG_BROADCAST(devgrp, grp, type, type2, state) \ - (devgrp 13 | 1 12 | grp 9 | type2 7 | type 4 | state) - -#define MSG_SINGULAR(devgrp, id, state) \ - (devgrp 13 | 0 12 | id 4 | state) - -#define R_PROTECT_KEY 0x0E -#define KEY_1 0xC0 -#define KEY_2 0x0C - -struct triton_ins { - u16 pmb_message; - u8 delay; -}; - - -#define CONFIG_DISABLE_HFCLK 1 - -#if defined(CONFIG_MACH_OMAP_3430SDP) || defined(CONFIG_MACH_OMAP_3430LABRADOR) - -struct triton_ins sleep_on_seq[] __initdata = { - {MSG_SINGULAR(DEV_GRP_P1, 0xf,
Re: disable_irq is broken in linux-omap-git
On Mon, Oct 13, 2008 at 2:51 AM, TK, Pratheesh Gangadhar [EMAIL PROTECTED] wrote: FYI, this seems to be currently broken as default_disable in kernel/irq/chip.c is defined to be an EMPTY function. It will affect drivers using disable_irq and following patch fixes it. It has been an empty function for more than a year and a half -- see the following patch for the reason it was removed: http://source.mvista.com/git/gitweb.cgi?p=linux-omap-2.6.git;a=commit;h=76d2160147f43f982dfe881404cfde9fd0a9da21 -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
disable_irq is broken in linux-omap-git
FYI, this seems to be currently broken as default_disable in kernel/irq/chip.c is defined to be an EMPTY function. It will affect drivers using disable_irq and following patch fixes it. static void default_disable(unsigned int irq) { + struct irq_desc *desc = irq_desc + irq; + + desc-chip-mask(irq); + desc-status |= IRQ_MASKED; + } Regards, Pratheesh -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 1/5] HDQ Driver for OMAP2430/3430
On Mon, 13 Oct 2008 18:55:43 +0530 Madhusudhan Chikkature [EMAIL PROTECTED] wrote: - Original Message - From: Andrew Morton [EMAIL PROTECTED] To: Gadiyar, Anand [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED]; linux-omap@vger.kernel.org; [EMAIL PROTECTED] Sent: Saturday, October 11, 2008 2:08 AM Subject: Re: [PATCH 1/5] HDQ Driver for OMAP2430/3430 + /* set the GO bit */ + hdq_reg_merge(hdq_data, OMAP_HDQ_CTRL_STATUS, OMAP_HDQ_CTRL_STATUS_GO, + OMAP_HDQ_CTRL_STATUS_DIR | OMAP_HDQ_CTRL_STATUS_GO); + /* wait for the TXCOMPLETE bit */ + ret = wait_event_interruptible_timeout(hdq_wait_queue, + hdq_data-hdq_irqstatus, OMAP_HDQ_TIMEOUT); + if (ret 0) { + dev_dbg(hdq_data-dev, wait interrupted); + return -EINTR; + } Is this desirable? The user hits ^C and the driver bails out? I assume so, but was this tested? Andrew, What is the test scenario you mean here? A user hitting ^C when the driver is waiting for the TXCOMPLETE bit? Yes. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: disable_irq is broken in linux-omap-git
-Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Sakoman Sent: Monday, October 13, 2008 9:21 PM To: linux-omap@vger.kernel.org Subject: Re: disable_irq is broken in linux-omap-git It has been an empty function for more than a year and a half -- see the following patch for the reason it was removed: http://source.mvista.com/git/gitweb.cgi?p=linux-omap-2.6.git;a=commit;h=76d2160147f43f982dfe881404cfde9fd0a9da21 Ok, but it does not seem that OMAP tree supplies disable handler either - so disable_irq is not recommended ? arch/arm/mach-omap2/irq.c static struct irq_chip omap_irq_chip = { .name = INTC, .ack= omap_mask_ack_irq, .mask = omap_mask_irq, .unmask = omap_unmask_irq, }; arch/arm/plat-omap/gpio.c static struct irq_chip mpuio_irq_chip = { .name = MPUIO, .ack= mpuio_ack_irq, .mask = mpuio_mask_irq, .unmask = mpuio_unmask_irq, .set_type = gpio_irq_type, #ifdef CONFIG_ARCH_OMAP16XX /* REVISIT: assuming only 16xx supports MPUIO wake events */ .set_wake = gpio_wake_enable, #endif }; static struct irq_chip gpio_irq_chip = { .name = GPIO, .shutdown = gpio_irq_shutdown, .ack= gpio_ack_irq, .mask = gpio_mask_irq, .unmask = gpio_unmask_irq, .set_type = gpio_irq_type, .set_wake = gpio_wake_enable, }; Regards, Pratheesh -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
RE: disable_irq is broken in linux-omap-git
On Mon, Oct 13, 2008 at 2:51 AM, TK, Pratheesh Gangadhar [EMAIL PROTECTED] wrote: FYI, this seems to be currently broken as default_disable in kernel/irq/chip.c is defined to be an EMPTY function. It will affect drivers using disable_irq and following patch fixes it. It has been an empty function for more than a year and a half -- see the following patch for the reason it was removed: http://source.mvista.com/git/gitweb.cgi?p=linux-omap- 2.6.git;a=commit;h=76d2160147f43f982dfe881404cfde9fd0a9da21 That comment seems fairly x86 specific. Instead imposing on everyone else it would have been nice for them to install a dummy handler in the irq-chip setup. Regards, Richard W. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
android on omap, yaffs2 or init problem
The issue I'm running into (see further below) in trying to start android on an OMAP is a dalvikvm-gc error during an ashmem allocation immediately at startup. An older posting indicates some differences in the android init/boot model. Can anyone expand on the android init/boot model? I see on the emulator that rootfs is mounted on / and is not yaffs2, while /system, /data, and /cache are yaffs2. I can successfully mount the rootfs (including system, data, and cache) via yaffs2 but run into the issue described below. Since I've got the yaffs2 mounts OK for system, data and cache (init.rc seems to automatically handle that) how can I configure file system and kernel args such that linux mounts rootfs on / like on emulator? I feel like I'm missing something very simple since (as described below in snippet from separate thread) I get much further into the android startup when mounting rootfs via NFS or JFFS2. And, when creating the android filesystem (per elinux.org's 'android on omap') should ramdisk.img instead be left in file form and used as an initrd image? I'm not very familiar with booting linux via initrd/initramfs. Thanks, twebb ** from old linux-omap post (2008-04-29) ** [Jonathan Herriott [EMAIL PROTECTED]] I had it confirmed in another thread that the issue is that the local filesystem for the N810 is jffs, which is unsupported and I need to install it on an mini SD card with ext2/ext3 on it. I think what you're seeing here is the property service in init failing to create and mmap it's arena, which it tries to do in /, which in our world is initramfs. The android init/boot model is a little different in that we don't pivot over to a root filesystem, we mount the system, data, etc partitions under the ramfs on / You might be able to hack around this by editing the string /system_properties to /tmp/em_properties or something like that, assuming you have tmpfs mounted on /tmp. Brian ** -- Forwarded message -- From: twebb [EMAIL PROTECTED] Date: Thu, Oct 9, 2008 at 6:00 PM Subject: Re: android on omap To: Deacon, Keith [EMAIL PROTECTED] Cc: Adrian Hunter [EMAIL PROTECTED], linux-omap@vger.kernel.org Mailing List linux-omap@vger.kernel.org, [EMAIL PROTECTED] [EMAIL PROTECTED], Mat Johnson [EMAIL PROTECTED] Ashmem is the Android shared memory subsystem. You can find it in the kernel under mm/ashmem.c. There is a config option to turn it on and off. The error indicates that it's having trouble with the driver - although it's not specific as to exactly what. Make sure it's enabled, the device is present (/dev/ashmem), etc.. ...Kd I have ashmem properly configured and it works when the FS is mounted via NFS. However as pointed out previously that seemed to be causing other issues so I moved the FS into JFFS2. That too had it's issues (where mmap was failing under certain conditions) that Adrian and Anil pointed out were due to JFFS2. So I moved it to YAFFS2. Now I'm seeing this ashmem issue. Up to this point, ashmem has worked fine so I don't believe it's really the culprit. I feel like it has to do with permissions or the filesystem. One difference is that the emulator uses three different yaffs2 partitions (userdata, system, and cache) while I currently have all of these on a single partition. Any other ideas as to what might cause the ... E/dalvikvm-gc( 483): Could not create 176128-byte ashmem mark stack message? Thanks, twebb -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 2.6.27-omap-git+ 0/5] twl4030 GPIO updates
Following this are several patches making the twl4030 GPIO code fit better into the GPIO framework, updating its only current user (hsmmc glue) and adding one more (Beagle). - gpio_request()/gpio_free() hook, now in MM for 2.6.28-rc merge - use that mechanism for twl4040 GPIOs - remove most twl-specific calls from mach-omap2/hsmmc.c glue - support LEDA and LEDB as output-only GPIOs - support those two LED signals on Beagle (one is a real LED!) This goes on top of the preceding patches to update IRQ handling for the twl core. Capsule summary: the only remaining twl40-specific GPIO calls are to enable hardware debouncing, with potential upstream generic support soon; and disabled linkages of the MMC power supplies to those card detect lines (best suited IMO to platform_data, once it's tested). Which makes twl4030-gpio nearly ready to go upstream. -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html
[patch 2.6.27-omap-git+ 1/5] gpiolib request/free hooks
From: David Brownell [EMAIL PROTECTED] Add a new internal mechanism to gpiolib to support low power operations by letting gpio_chip instances see when their GPIOs are in use. When no GPIOs are active, chips may be able to enter lower powered runtime states by disabling clocks and/or power domains. Signed-off-by: David Brownell [EMAIL PROTECTED] Signed-off-by: Andrew Morton [EMAIL PROTECTED] --- Documentation/gpio.txt |4 + drivers/gpio/gpiolib.c | 91 --- include/asm-generic/gpio.h |9 3 files changed, 91 insertions(+), 13 deletions(-) --- a/Documentation/gpio.txt +++ b/Documentation/gpio.txt @@ -240,6 +240,10 @@ signal, or (b) something wrongly believe needed to manage a signal that's in active use. That is, requesting a GPIO can serve as a kind of lock. +Some platforms may also use knowledge about what GPIOs are active for +power management, such as by powering down unused chip sectors and, more +easily, gating off unused clocks. + These two calls are optional because not not all current Linux platforms offer such functionality in their GPIO support; a valid implementation could return success for all gpio_request() calls. Unlike the other calls, --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -67,17 +67,28 @@ static inline void desc_set_label(struct * when setting direction, and otherwise illegal. Until board setup code * and drivers use explicit requests everywhere (which won't happen when * those calls have no teeth) we can't avoid autorequesting. This nag - * message should motivate switching to explicit requests... + * message should motivate switching to explicit requests... so should + * the weaker cleanup after faults, compared to gpio_request(). */ -static void gpio_ensure_requested(struct gpio_desc *desc) +static int gpio_ensure_requested(struct gpio_desc *desc, unsigned offset) { if (test_and_set_bit(FLAG_REQUESTED, desc-flags) == 0) { - pr_warning(GPIO-%d autorequested\n, (int)(desc - gpio_desc)); + struct gpio_chip *chip = desc-chip; + int gpio = chip-base + offset; + + if (!try_module_get(chip-owner)) { + pr_err(GPIO-%d: module can't be gotten \n, gpio); + clear_bit(FLAG_REQUESTED, desc-flags); + /* lose */ + return -EIO; + } + pr_warning(GPIO-%d autorequested\n, gpio); desc_set_label(desc, [auto]); - if (!try_module_get(desc-chip-owner)) - pr_err(GPIO-%d: module can't be gotten \n, - (int)(desc - gpio_desc)); + /* caller must chip-request() w/o spinlock */ + if (chip-request) + return 1; } + return 0; } /* caller holds gpio_lock *OR* gpio is marked as requested */ @@ -752,6 +763,7 @@ EXPORT_SYMBOL_GPL(gpiochip_remove); int gpio_request(unsigned gpio, const char *label) { struct gpio_desc*desc; + struct gpio_chip*chip; int status = -EINVAL; unsigned long flags; @@ -760,14 +772,15 @@ int gpio_request(unsigned gpio, const ch if (!gpio_is_valid(gpio)) goto done; desc = gpio_desc[gpio]; - if (desc-chip == NULL) + chip = desc-chip; + if (chip == NULL) goto done; - if (!try_module_get(desc-chip-owner)) + if (!try_module_get(chip-owner)) goto done; /* NOTE: gpio_request() can be called in early boot, -* before IRQs are enabled. +* before IRQs are enabled, for non-sleeping (SOC) GPIOs. */ if (test_and_set_bit(FLAG_REQUESTED, desc-flags) == 0) { @@ -775,7 +788,20 @@ int gpio_request(unsigned gpio, const ch status = 0; } else { status = -EBUSY; - module_put(desc-chip-owner); + module_put(chip-owner); + } + + if (chip-request) { + /* chip-request may sleep */ + spin_unlock_irqrestore(gpio_lock, flags); + status = chip-request(chip, gpio - chip-base); + spin_lock_irqsave(gpio_lock, flags); + + if (status 0) { + desc_set_label(desc, NULL); + module_put(chip-owner); + clear_bit(FLAG_REQUESTED, desc-flags); + } } done: @@ -791,6 +817,7 @@ void gpio_free(unsigned gpio) { unsigned long flags; struct gpio_desc*desc; + struct gpio_chip*chip; if (!gpio_is_valid(gpio)) { WARN_ON(extra_checks); @@ -802,9 +829,17 @@ void gpio_free(unsigned gpio) spin_lock_irqsave(gpio_lock, flags); desc = gpio_desc[gpio]; - if (desc-chip
[patch 2.6.27-omap-git+ 3/5] hsmmc.c glue uses standard GPIO calls
From: David Brownell [EMAIL PROTECTED] Convert the hsmmc init code over to standard GPIO calls: gpio_request(), gpio_free(), gpio_get_value_cansleep(). NOTE that this doesn't pass GPIO numbers in to hsmmc_init(); those values are still hard-wired. (For the write protect signal, the LACK of value is hard-wired...) So the hsmmc glue is still kind of problematic. Signed-off-by: David Brownell [EMAIL PROTECTED] --- arch/arm/mach-omap2/hsmmc.c | 25 - drivers/gpio/twl4030-gpio.c | 28 +--- include/linux/i2c/twl4030.h |4 3 files changed, 13 insertions(+), 44 deletions(-) --- a/arch/arm/mach-omap2/hsmmc.c +++ b/arch/arm/mach-omap2/hsmmc.c @@ -15,7 +15,9 @@ #include linux/platform_device.h #include linux/interrupt.h #include linux/delay.h +#include linux/gpio.h #include linux/i2c/twl4030.h + #include mach/hardware.h #include mach/mmc.h #include mach/board.h @@ -32,8 +34,6 @@ #define LDO_CLR0x00 #define VSEL_S2_CLR0x40 #define GPIO_0_BIT_POS (1 0) -#define MMC1_CD_IRQ0 -#define MMC2_CD_IRQ1 #define OMAP2_CONTROL_DEVCONF0 0x48002274 #define OMAP2_CONTROL_DEVCONF1 0x490022E8 @@ -45,9 +45,12 @@ #define OMAP2_CONTROL_PBIAS_PWRDNZ (1 1) #define OMAP2_CONTROL_PBIAS_SCTRL (1 2) + +static const int mmc1_cd_gpio = OMAP_MAX_GPIO_LINES; /* HACK!! */ + static int hsmmc_card_detect(int irq) { - return twl4030_get_gpio_datain(irq - TWL4030_GPIO_IRQ_BASE); + return gpio_get_value_cansleep(mmc1_cd_gpio); } /* @@ -60,11 +63,11 @@ static int hsmmc_late_init(struct device /* * Configure TWL4030 GPIO parameters for MMC hotplug irq */ - ret = twl4030_request_gpio(MMC1_CD_IRQ); + ret = gpio_request(mmc1_cd_gpio, mmc0_cd); if (ret) goto err; - ret = twl4030_set_gpio_debounce(MMC1_CD_IRQ, TWL4030_GPIO_IS_ENABLE); + ret = twl4030_set_gpio_debounce(0, true); if (ret) goto err; @@ -77,11 +80,7 @@ err: static void hsmmc_cleanup(struct device *dev) { - int ret = 0; - - ret = twl4030_free_gpio(MMC1_CD_IRQ); - if (ret) - dev_err(dev, Failed to configure TWL4030 GPIO IRQ\n); + gpio_free(mmc1_cd_gpio); } #ifdef CONFIG_PM @@ -123,7 +122,7 @@ static int hsmmc_suspend(struct device * { int ret = 0; - disable_irq(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ)); + disable_irq(TWL4030_GPIO_IRQ_NO(0)); ret = mask_cd_interrupt(1); return ret; @@ -133,7 +132,7 @@ static int hsmmc_resume(struct device *d { int ret = 0; - enable_irq(TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ)); + enable_irq(TWL4030_GPIO_IRQ_NO(0)); ret = mask_cd_interrupt(0); return ret; @@ -260,7 +259,7 @@ static struct omap_mmc_platform_data mmc MMC_VDD_165_195, .name = first slot, - .card_detect_irq= TWL4030_GPIO_IRQ_NO(MMC1_CD_IRQ), + .card_detect_irq= TWL4030_GPIO_IRQ_NO(0), .card_detect= hsmmc_card_detect, }, }; --- a/drivers/gpio/twl4030-gpio.c +++ b/drivers/gpio/twl4030-gpio.c @@ -97,31 +97,6 @@ static inline int gpio_twl4030_read(u8 a return (ret 0) ? ret : data; } -/* - * twl4030 GPIO request function - */ -int twl4030_request_gpio(int gpio) -{ - if (unlikely(gpio = TWL4030_GPIO_MAX)) - return -EPERM; - - return gpio_request(twl_gpiochip.base + gpio, NULL); -} -EXPORT_SYMBOL(twl4030_request_gpio); - -/* - * TWL4030 GPIO free module - */ -int twl4030_free_gpio(int gpio) -{ - if (unlikely(gpio = TWL4030_GPIO_MAX)) - return -EPERM; - - gpio_free(twl_gpiochip.base + gpio); - return 0; -} -EXPORT_SYMBOL(twl4030_free_gpio); - static int twl4030_set_gpio_direction(int gpio, int is_input) { u8 d_bnk = gpio 3; @@ -158,7 +133,7 @@ static int twl4030_set_gpio_dataout(int return gpio_twl4030_write(base, d_msk); } -int twl4030_get_gpio_datain(int gpio) +static int twl4030_get_gpio_datain(int gpio) { u8 d_bnk = gpio 3; u8 d_off = gpio 0x7; @@ -176,7 +151,6 @@ int twl4030_get_gpio_datain(int gpio) return ret; } -EXPORT_SYMBOL(twl4030_get_gpio_datain); /* * Configure debounce timing value for a GPIO pin on TWL4030 --- a/include/linux/i2c/twl4030.h +++ b/include/linux/i2c/twl4030.h @@ -319,17 +319,13 @@ int twl4030_sih_setup(int module); /* TWL4030 GPIO interrupt definitions */ #define TWL4030_GPIO_IRQ_NO(n) (TWL4030_GPIO_IRQ_BASE + (n)) -#define TWL4030_GPIO_IS_ENABLE 1 /* * Exported TWL4030 GPIO APIs * * WARNING -- use standard GPIO and IRQ calls instead; these will vanish. */ -int twl4030_get_gpio_datain(int gpio); -int twl4030_request_gpio(int gpio); int
[patch 2.6.27-omap-git+ 4/5] twl4030-gpio supports LED signals
From: David Brownell [EMAIL PROTECTED] Expose the two TWL4030 LED signals as output-only GPIOs. Boards need to explicitly ask that this be done, to help avoid conflicts on boards using these same pins to hook up to a vibrator motor. Note that these are high drive open drain signals; LEDA is rated for up to 160 mA (!), LEDB up to 60 mA. Boards using one of these signals to drive a bank of LCD backlight LEDs would probably want to access the dedicated PWMs for brightness control, too; easy to add such support later. Example: Beagle has one real LED here (PWM not necessary), and one GPIO controlling VBUS output over EHCI (PWM not wanted). Signed-off-by: David Brownell [EMAIL PROTECTED] --- drivers/gpio/twl4030-gpio.c | 129 -- include/linux/i2c/twl4030.h |3 2 files changed, 126 insertions(+), 6 deletions(-) --- a/drivers/gpio/twl4030-gpio.c +++ b/drivers/gpio/twl4030-gpio.c @@ -85,6 +85,32 @@ static inline int gpio_twl4030_write(u8 return twl4030_i2c_write_u8(TWL4030_MODULE_GPIO, data, address); } +/*--*/ + +/* + * LED register offsets (use TWL4030_MODULE_{LED,PWMA,PWMB})) + * PWMs A and B are dedicated to LEDs A and B, respectively. + */ + +#define TWL4030_LED_LEDEN 0x0 + +/* LEDEN bits */ +#define LEDEN_LEDAON BIT(0) +#define LEDEN_LEDBON BIT(1) +#define LEDEN_LEDAEXT BIT(2) +#define LEDEN_LEDBEXT BIT(3) +#define LEDEN_LEDAPWM BIT(4) +#define LEDEN_LEDBPWM BIT(5) +#define LEDEN_PWM_LENGTHA BIT(6) +#define LEDEN_PWM_LENGTHB BIT(7) + +#define TWL4030_PWMx_PWMxON0x0 +#define TWL4030_PWMx_PWMxOFF 0x1 + +#define PWMxON_LENGTH BIT(7) + +/*--*/ + /* * To read a TWL4030 GPIO module register */ @@ -97,6 +123,32 @@ static inline int gpio_twl4030_read(u8 a return (ret 0) ? ret : data; } +/*--*/ + +static u8 cached_leden;/* protected by gpio_lock */ + +/* The LED lines are open drain outputs ... a FET pulls to GND, so an + * external pullup is needed. We could also expose the integrated PWM + * as a LED brightness control; we initialize it as always on. + */ +static void twl4030_led_set_value(int led, int value) +{ + u8 mask = LEDEN_LEDAON | LEDEN_LEDAPWM; + int status; + + if (led) + mask = 1; + + mutex_lock(gpio_lock); + if (value) + cached_leden = ~mask; + else + cached_leden |= mask; + status = twl4030_i2c_write_u8(TWL4030_MODULE_LED, cached_leden, + TWL4030_LED_LEDEN); + mutex_unlock(gpio_lock); +} + static int twl4030_set_gpio_direction(int gpio, int is_input) { u8 d_bnk = gpio 3; @@ -226,6 +278,44 @@ static int twl_request(struct gpio_chip mutex_lock(gpio_lock); + /* Support the two LED outputs as output-only GPIOs. */ + if (offset = TWL4030_GPIO_MAX) { + u8 ledclr_mask = LEDEN_LEDAON | LEDEN_LEDAEXT + | LEDEN_LEDAPWM | LEDEN_PWM_LENGTHA; + u8 module = TWL4030_MODULE_PWMA; + + offset -= TWL4030_GPIO_MAX; + if (offset) { + ledclr_mask = 1; + module = TWL4030_MODULE_PWMB; + } + + /* initialize PWM to always-drive */ + status = twl4030_i2c_write_u8(module, 0x7f, + TWL4030_PWMx_PWMxOFF); + if (status 0) + goto done; + status = twl4030_i2c_write_u8(module, 0x7f, + TWL4030_PWMx_PWMxON); + if (status 0) + goto done; + + /* init LED to not-driven (high) */ + module = TWL4030_MODULE_LED; + status = twl4030_i2c_read_u8(module, cached_leden, + TWL4030_LED_LEDEN); + if (status 0) + goto done; + cached_leden = ~ledclr_mask; + status = twl4030_i2c_write_u8(module, cached_leden, + TWL4030_LED_LEDEN); + if (status 0) + goto done; + + status = 0; + goto done; + } + /* on first use, turn GPIO module on */ if (!gpio_usage_count) status = gpio_twl4030_write(REG_GPIO_CTRL, @@ -241,6 +331,11 @@ done: static void twl_free(struct gpio_chip *chip, unsigned offset) { + if (offset = TWL4030_GPIO_MAX) { + twl4030_led_set_value(offset - TWL4030_GPIO_MAX, 1); + return; + } + mutex_lock(gpio_lock); gpio_usage_count = ~BIT(offset); @@ -254,30 +349,46 @@ static
[patch 2.6.27-omap-git+ 2/5] twl4030-gpio use new gpiolib hooks
From: David Brownell [EMAIL PROTECTED] Use the new gpiolib internal mechanism for tracking gpio usage, making them power the GPIO module on/off, so that the standard gpio_request()/gpio_free() calls can completely replace the twl4030-specific versions. Signed-off-by: David Brownell [EMAIL PROTECTED] --- drivers/gpio/twl4030-gpio.c | 77 -- 1 file changed, 37 insertions(+), 40 deletions(-) --- a/drivers/gpio/twl4030-gpio.c +++ b/drivers/gpio/twl4030-gpio.c @@ -102,32 +102,10 @@ static inline int gpio_twl4030_read(u8 a */ int twl4030_request_gpio(int gpio) { - int ret = 0; - if (unlikely(gpio = TWL4030_GPIO_MAX)) return -EPERM; - ret = gpio_request(twl_gpiochip.base + gpio, NULL); - if (ret 0) - return ret; - - mutex_lock(gpio_lock); - if (gpio_usage_count BIT(gpio)) { - ret = -EBUSY; - } else { - /* First time usage? - switch on GPIO module */ - if (!gpio_usage_count) { - ret = gpio_twl4030_write(REG_GPIO_CTRL, - MASK_GPIO_CTRL_GPIO_ON); - - } - if (!ret) - gpio_usage_count |= BIT(gpio); - else - gpio_free(twl_gpiochip.base + gpio); - } - mutex_unlock(gpio_lock); - return ret; + return gpio_request(twl_gpiochip.base + gpio, NULL); } EXPORT_SYMBOL(twl4030_request_gpio); @@ -136,26 +114,11 @@ EXPORT_SYMBOL(twl4030_request_gpio); */ int twl4030_free_gpio(int gpio) { - int ret = 0; - if (unlikely(gpio = TWL4030_GPIO_MAX)) return -EPERM; - mutex_lock(gpio_lock); - - if ((gpio_usage_count BIT(gpio)) == 0) { - ret = -EPERM; - } else { - gpio_usage_count = ~BIT(gpio); - gpio_free(twl_gpiochip.base + gpio); - } - - /* Last time usage? - switch off GPIO module */ - if (ret == 0 !gpio_usage_count) - ret = gpio_twl4030_write(REG_GPIO_CTRL, 0x0); - - mutex_unlock(gpio_lock); - return ret; + gpio_free(twl_gpiochip.base + gpio); + return 0; } EXPORT_SYMBOL(twl4030_free_gpio); @@ -283,6 +246,38 @@ int twl4030_set_gpio_card_detect(int gpi /*--*/ +static int twl_request(struct gpio_chip *chip, unsigned offset) +{ + int status = 0; + + mutex_lock(gpio_lock); + + /* on first use, turn GPIO module on */ + if (!gpio_usage_count) + status = gpio_twl4030_write(REG_GPIO_CTRL, + MASK_GPIO_CTRL_GPIO_ON); + + if (!status) + gpio_usage_count |= (0x1 offset); + +done: + mutex_unlock(gpio_lock); + return status; +} + +static void twl_free(struct gpio_chip *chip, unsigned offset) +{ + mutex_lock(gpio_lock); + + gpio_usage_count = ~BIT(offset); + + /* on last use, switch off GPIO module */ + if (!gpio_usage_count) + gpio_twl4030_write(REG_GPIO_CTRL, 0x0); + + mutex_unlock(gpio_lock); +} + static int twl_direction_in(struct gpio_chip *chip, unsigned offset) { return twl4030_set_gpio_direction(offset, 1); @@ -316,6 +311,8 @@ static int twl_to_irq(struct gpio_chip * static struct gpio_chip twl_gpiochip = { .label = twl4030, .owner = THIS_MODULE, + .request= twl_request, + .free = twl_free, .direction_input= twl_direction_in, .get= twl_get, .direction_output = twl_direction_out, -- To unsubscribe from this list: send the line unsubscribe linux-omap in the body of a message to [EMAIL PROTECTED] More majordomo info at http://vger.kernel.org/majordomo-info.html