From 9ecc089861ab238e391de368142cc17b2f715cf7 Mon Sep 17 00:00:00 2001 From: Timo Juhani Lindfors Date: Tue, 28 Apr 2009 12:22:46 -0500 Subject: Call unbind() hook of the usb gadget so that it can properly release its resources Call unbind() hook of the gadget so that it can properly release its resources. This fixes bug http://docs.openmoko.org/trac/ticket/2240 ("removing/reloading g_ether not working"). All other instances of usb_gadget_unregister_driver in Linux already call unbind() so it is bit odd s3c2410_udc.c did not do so. Signed-off-by: Timo Juhani Lindfors --- drivers/usb/gadget/s3c2410_udc.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 1a185c1194e..891bab74b8c 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -1713,6 +1713,7 @@ int usb_gadget_unregister_driver(struct usb_gadget_driver *driver) if (driver->disconnect) driver->disconnect(&udc->gadget); + driver->unbind(&udc->gadget); device_del(&udc->gadget.dev); udc->driver = NULL; -- cgit v1.2.3 From 4c9a8d5badc466a68d71754d47bbb792a8dc44da Mon Sep 17 00:00:00 2001 From: Nelson Castillo Date: Tue, 28 Apr 2009 18:58:05 -0500 Subject: GTA01: Add "present" property to power_supply Small patch to add /sys/class/power_supply/battery/present. You must not run a GTA01 without battery thus it is always 1. Signed-off-by: Nelson Castillo --- drivers/power/gta01_battery.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'drivers') diff --git a/drivers/power/gta01_battery.c b/drivers/power/gta01_battery.c index 909f7fe16d9..81a0fe7387e 100644 --- a/drivers/power/gta01_battery.c +++ b/drivers/power/gta01_battery.c @@ -19,6 +19,7 @@ struct gta01_battery { }; static enum power_supply_property gta01_bat_props[] = { + POWER_SUPPLY_PROP_PRESENT, POWER_SUPPLY_PROP_STATUS, POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CURRENT_NOW, @@ -43,6 +44,9 @@ static int gta01_bat_get_property(struct power_supply *psy, case POWER_SUPPLY_PROP_CURRENT_NOW: val->intval = bat->pdata->get_current(); break; + case POWER_SUPPLY_PROP_PRESENT: + val->intval = 1; /* You must never run GTA01 without battery. */ + break; default: return -EINVAL; } -- cgit v1.2.3 From 1f4e63aada245db8f087747f2eb715ccf95f3797 Mon Sep 17 00:00:00 2001 From: Rask Ingemann Lambertsen Date: Wed, 6 May 2009 02:36:00 +0200 Subject: Glamo MFD: Fix indentation of Kconfig, convert spaces to tabs This patch fixes some indentation which was off by one and converts spaces to tabs. Signed-off-by: Rask Ingemann Lambertsen --- drivers/mfd/glamo/Kconfig | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'drivers') diff --git a/drivers/mfd/glamo/Kconfig b/drivers/mfd/glamo/Kconfig index 60d29c92ef1..6d93a5d926e 100644 --- a/drivers/mfd/glamo/Kconfig +++ b/drivers/mfd/glamo/Kconfig @@ -33,18 +33,19 @@ config MFD_GLAMO_FB_XGLAMO_WORKAROUND config MFD_GLAMO_SPI_GPIO - tristate "Glamo GPIO SPI bitbang support" - depends on MFD_GLAMO - help - Enable a bitbanging SPI adapter driver for the Smedia Glamo. + tristate "Glamo GPIO SPI bitbang support" + depends on MFD_GLAMO + + help + Enable a bitbanging SPI adapter driver for the Smedia Glamo. config MFD_GLAMO_SPI_FB - tristate "Glamo LCM control channel SPI support" - depends on MFD_GLAMO_FB - help - Enable a bitbanging SPI adapter driver for the Smedia Glamo LCM - control channel. This SPI interface is frequently used to - interconnect the LCM control interface. + tristate "Glamo LCM control channel SPI support" + depends on MFD_GLAMO_FB + help + Enable a bitbanging SPI adapter driver for the Smedia Glamo LCM + control channel. This SPI interface is frequently used to + interconnect the LCM control interface. config MFD_GLAMO_MCI tristate "Glamo S3C SD/MMC Card Interface support" -- cgit v1.2.3 From f656a97d946a2529630c9770a72c10a24dc397f9 Mon Sep 17 00:00:00 2001 From: Rask Ingemann Lambertsen Date: Wed, 6 May 2009 02:41:24 +0200 Subject: Glamo MFD: MFD_GLAMO_SPI_GPIO requires SPI_BITBANG to build This patch fixes a linking failure in the Glamo GPIO SPI bitbang support. Signed-off-by: Rask Ingemann Lambertsen --- drivers/mfd/glamo/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers') diff --git a/drivers/mfd/glamo/Kconfig b/drivers/mfd/glamo/Kconfig index 6d93a5d926e..efa16990d57 100644 --- a/drivers/mfd/glamo/Kconfig +++ b/drivers/mfd/glamo/Kconfig @@ -35,6 +35,7 @@ config MFD_GLAMO_FB_XGLAMO_WORKAROUND config MFD_GLAMO_SPI_GPIO tristate "Glamo GPIO SPI bitbang support" depends on MFD_GLAMO + select SPI_BITBANG help Enable a bitbanging SPI adapter driver for the Smedia Glamo. -- cgit v1.2.3 From 4fc401c9b26be1765de71791e15e59093df94eac Mon Sep 17 00:00:00 2001 From: Nelson Castillo Date: Thu, 14 May 2009 23:46:41 -0500 Subject: Avoid null pointer access on early call to pcf50633_mbc_get_status Avoid a kernel panic during an early call to the pcf50633_mbc_get_status function. --- drivers/power/pcf50633-charger.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers') diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c index 8772604ae1a..1bdb9906201 100644 --- a/drivers/power/pcf50633-charger.c +++ b/drivers/power/pcf50633-charger.c @@ -114,6 +114,9 @@ int pcf50633_mbc_get_status(struct pcf50633 *pcf) struct pcf50633_mbc *mbc = platform_get_drvdata(pcf->mbc_pdev); int status = 0; + if (!mbc) + return 0; + if (mbc->usb_online) status |= PCF50633_MBC_USB_ONLINE; if (mbc->usb_active) -- cgit v1.2.3 From aded5330d196644b0f16423dfde9bb2344d991d5 Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Thu, 26 Mar 2009 00:45:27 -0700 Subject: usb gadget: fix ethernet link reports to ethtool The g_ether USB gadget driver currently decides whether or not there's a link to report back for eth_get_link based on if the USB link speed is set. The USB gadget speed is however often set even before the device is enumerated. It seems more sensible to only report a "link" if we're actually connected to a host that wants to talk to us. The patch below does this for me - tested with the PXA27x UDC driver. Signed-off-by: Jonathan McDowell Signed-off-by: David Brownell Cc: stable Signed-off-by: Greg Kroah-Hartman --- drivers/usb/gadget/u_ether.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) (limited to 'drivers') diff --git a/drivers/usb/gadget/u_ether.c b/drivers/usb/gadget/u_ether.c index 96d65ca06ec..4007770f7ed 100644 --- a/drivers/usb/gadget/u_ether.c +++ b/drivers/usb/gadget/u_ether.c @@ -175,12 +175,6 @@ static void eth_get_drvinfo(struct net_device *net, struct ethtool_drvinfo *p) strlcpy(p->bus_info, dev_name(&dev->gadget->dev), sizeof p->bus_info); } -static u32 eth_get_link(struct net_device *net) -{ - struct eth_dev *dev = netdev_priv(net); - return dev->gadget->speed != USB_SPEED_UNKNOWN; -} - /* REVISIT can also support: * - WOL (by tracking suspends and issuing remote wakeup) * - msglevel (implies updated messaging) @@ -189,7 +183,7 @@ static u32 eth_get_link(struct net_device *net) static struct ethtool_ops ops = { .get_drvinfo = eth_get_drvinfo, - .get_link = eth_get_link + .get_link = ethtool_op_get_link, }; static void defer_kevent(struct eth_dev *dev, int flag) -- cgit v1.2.3 From 37d2b0bea0314d0947af19152898c1ca7fe736cc Mon Sep 17 00:00:00 2001 From: Mike Westerhof Date: Wed, 13 May 2009 20:11:06 -0500 Subject: This patch adds the option to poll vbus status to the s3c24xx udc driver. Machines that do not route the USB vbus signal to a GPIO can use this mechanism as an alternate way for the udc driver to detect the usb connect/disconnect state, which is useful (for example) to enable the link up/down state to be determined for the g_ether gadget. Signed-off-by: Mike Westerhof --- drivers/usb/gadget/s3c2410_udc.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'drivers') diff --git a/drivers/usb/gadget/s3c2410_udc.c b/drivers/usb/gadget/s3c2410_udc.c index 891bab74b8c..c8dca979b04 100644 --- a/drivers/usb/gadget/s3c2410_udc.c +++ b/drivers/usb/gadget/s3c2410_udc.c @@ -74,6 +74,7 @@ static void __iomem *base_addr; static u64 rsrc_start; static u64 rsrc_len; static struct dentry *s3c2410_udc_debugfs_root; +static struct timer_list vbus_poll_timer; static inline u32 udc_read(u32 reg) { @@ -1526,6 +1527,20 @@ static irqreturn_t s3c2410_udc_vbus_irq(int irq, void *_dev) return IRQ_HANDLED; } +static void s3c2410_udc_vbus_poll(unsigned long _data) +{ + struct s3c2410_udc *data = (struct s3c2410_udc *)_data; + int v; + + dprintk(DEBUG_NORMAL, "%s()\n", __func__); + if (udc_info && udc_info->get_vbus_status) { + v = udc_info->get_vbus_status(); + if ((v > -1) && (v != data->vbus)) + s3c2410_udc_vbus_session(&data->gadget, v); + mod_timer(&vbus_poll_timer, jiffies + msecs_to_jiffies(900)); + } +} + static int s3c2410_vbus_draw(struct usb_gadget *_gadget, unsigned ma) { dprintk(DEBUG_NORMAL, "%s()\n", __func__); @@ -1683,6 +1698,11 @@ int usb_gadget_register_driver(struct usb_gadget_driver *driver) goto register_error; } + if (udc_info && udc_info->get_vbus_status && !udc_info->vbus_pin) { + mod_timer(&vbus_poll_timer, jiffies + msecs_to_jiffies(50)); + return 0; /* just return, vbus change will enable udc */ + } + /* Enable udc */ s3c2410_udc_enable(udc); @@ -1900,6 +1920,11 @@ static int s3c2410_udc_probe(struct platform_device *pdev) } dev_dbg(dev, "got irq %i\n", irq); + } else if (udc_info && udc_info->get_vbus_status) { + udc->vbus = 0; + init_timer(&vbus_poll_timer); + vbus_poll_timer.function = s3c2410_udc_vbus_poll; + vbus_poll_timer.data = (unsigned long) udc; } else { udc->vbus = 1; } @@ -1948,6 +1973,8 @@ static int s3c2410_udc_remove(struct platform_device *pdev) if (udc_info && udc_info->vbus_pin > 0) { irq = gpio_to_irq(udc_info->vbus_pin); free_irq(irq, udc); + } else if (udc_info && udc_info->get_vbus_status) { + del_timer_sync(&vbus_poll_timer); } free_irq(IRQ_USBD, udc); -- cgit v1.2.3 From 5b8138ba5c1dbc86dce264a0d4c078737aa2007a Mon Sep 17 00:00:00 2001 From: Michael Trimarchi Date: Sat, 23 May 2009 17:54:00 -0300 Subject: Improve battery status notification This patch adds a call to cancel_delayed_work before a call to schedule_delayed_work. Signed-off-by: Michael Trimarchi Signed-off-by: Daniel Willmann --- drivers/power/bq27000_battery.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/power/bq27000_battery.c b/drivers/power/bq27000_battery.c index 9f0f1a96720..7e8b3f8ad96 100644 --- a/drivers/power/bq27000_battery.c +++ b/drivers/power/bq27000_battery.c @@ -170,9 +170,11 @@ static int hdq_read16(struct bq27000_device_info *di, int address) static void bq27000_battery_external_power_changed(struct power_supply *psy) { - struct bq27000_device_info *di = container_of(psy, struct bq27000_device_info, bat); + struct bq27000_device_info *di = + container_of(psy, struct bq27000_device_info, bat); dev_dbg(di->dev, "%s\n", __FUNCTION__); + cancel_delayed_work(&di->work); schedule_delayed_work(&di->work, 0); } -- cgit v1.2.3 From dc91099c0ef18660bc2d9e3bd75fc1ad811e1116 Mon Sep 17 00:00:00 2001 From: Paul Fertser Date: Thu, 4 Jun 2009 23:40:52 +0400 Subject: GTA02: bq27000 report current charge Using HAL for E's battery gadget highlighted an oddity: the kernel exposed last full charge property but didn't expose current charge property. This resulted in the wrong computation of current battery capacity by E's gadget (and probably other programs as well). This patch exposes a corresponding bq27000 register to make E battery gadget happy (it is still not showing correct values because of bugs in HAL resulting in 3 batteries (apm emulation and usb supply being bogus here) instead of one). Signed-off-by: Paul Fertser --- drivers/power/bq27000_battery.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers') diff --git a/drivers/power/bq27000_battery.c b/drivers/power/bq27000_battery.c index 7e8b3f8ad96..593cbe6f752 100644 --- a/drivers/power/bq27000_battery.c +++ b/drivers/power/bq27000_battery.c @@ -115,6 +115,7 @@ struct bq27000_bat_regs { int ai; int flags; int lmd; + int nac; int rsoc; int temp; int tte; @@ -271,6 +272,11 @@ use_bat: return di->regs.lmd; val->intval = (di->regs.lmd * 3570) / di->pdata->rsense_mohms; break; + case POWER_SUPPLY_PROP_CHARGE_NOW: + if (di->regs.nac < 0) + return di->regs.nac; + val->intval = (di->regs.nac * 3570) / di->pdata->rsense_mohms; + break; case POWER_SUPPLY_PROP_TEMP: if (di->regs.temp < 0) return di->regs.temp; @@ -323,6 +329,7 @@ static void bq27000_battery_work(struct work_struct *work) regs.ai = hdq_read16(di, BQ27000_AI_L); regs.flags = (di->pdata->hdq_read)(BQ27000_FLAGS); regs.lmd = hdq_read16(di, BQ27000_LMD_L); + regs.nac = hdq_read16(di, BQ27000_NAC_L); regs.rsoc = (di->pdata->hdq_read)(BQ27000_RSOC); regs.temp = hdq_read16(di, BQ27000_TEMP_L); regs.tte = hdq_read16(di, BQ27000_TTE_L); @@ -345,6 +352,7 @@ static enum power_supply_property bq27000_battery_props[] = { POWER_SUPPLY_PROP_VOLTAGE_NOW, POWER_SUPPLY_PROP_CURRENT_NOW, POWER_SUPPLY_PROP_CHARGE_FULL, + POWER_SUPPLY_PROP_CHARGE_NOW, POWER_SUPPLY_PROP_TEMP, POWER_SUPPLY_PROP_TECHNOLOGY, POWER_SUPPLY_PROP_PRESENT, -- cgit v1.2.3