From 6e93b6081738bad7e9936ad1cae08cba98a8e16e Mon Sep 17 00:00:00 2001 From: supriya karanth Date: Fri, 9 Dec 2011 16:32:37 +0530 Subject: usb: musb: TXMAXP,TXCSR setting in Host mode The TXMAXP and TXCSR registers were not set correctly for the BULK OUT endpoints causing issues in Full speed in Host mode. ST-Ericsson Linux next: NA ST-Ericsson ID: 367049 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: If5f3552235d8909adef4777f08d612df432d8709 Signed-off-by: supriya karanth --- drivers/usb/musb/musb_host.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c index 04677af00e3..938377a50a9 100644 --- a/drivers/usb/musb/musb_host.c +++ b/drivers/usb/musb/musb_host.c @@ -640,7 +640,17 @@ static bool musb_tx_dma_program(struct dma_controller *dma, mode = 1; csr |= MUSB_TXCSR_DMAMODE | MUSB_TXCSR_DMAENAB; /* autoset shouldn't be set in high bandwidth */ - if (qh->hb_mult == 1) + /* + * Enable Autoset according to table + * below + * bulk_split hb_mult Autoset_Enable + * 0 1 Yes(Normal) + * 0 >1 No(High BW ISO) + * 1 1 Yes(HS bulk) + * 1 >1 Yes(FS bulk) + */ + if (qh->hb_mult == 1 || (qh->hb_mult > 1 && + can_bulk_split(hw_ep->musb, qh->type))) csr |= MUSB_TXCSR_AUTOSET; } else { mode = 0; @@ -787,6 +797,13 @@ static void musb_ep_program(struct musb *musb, u8 epnum, /* protocol/endpoint/interval/NAKlimit */ if (epnum) { musb_writeb(epio, MUSB_TXTYPE, qh->type_reg); + /* + * Set the TXMAXP register correctly for Bulk OUT + * endpoints in host mode + */ + if (can_bulk_split(musb, qh->type)) + qh->hb_mult = hw_ep->max_packet_sz_tx + / packet_sz; if (musb->double_buffer_not_ok) musb_writew(epio, MUSB_TXMAXP, hw_ep->max_packet_sz_tx); -- cgit v1.2.3 From c8a60ba6986b3094176f7c43527004812437e6b1 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Tue, 20 Dec 2011 12:42:12 +0100 Subject: Revert "usb: musb: drop a gigantic amount of ifdeferry" This reverts commit 622859634a663c5e55d0e2a2cdbb55ac058d97b3. Conflicts: drivers/usb/musb/musb_core.c --- drivers/usb/musb/Kconfig | 75 ++++++++++++++++++++++++++++++- drivers/usb/musb/Makefile | 4 +- drivers/usb/musb/am35x.c | 4 ++ drivers/usb/musb/blackfin.h | 2 +- drivers/usb/musb/da8xx.c | 12 ++++- drivers/usb/musb/davinci.c | 5 +++ drivers/usb/musb/musb_core.c | 92 +++++++++++++++++++++++++++++++++++++- drivers/usb/musb/musb_core.h | 68 ++++++++++++++++++++++++++++ drivers/usb/musb/musb_gadget.c | 4 ++ drivers/usb/musb/musb_gadget_ep0.c | 4 ++ drivers/usb/musb/musb_host.h | 4 ++ drivers/usb/musb/musb_virthub.c | 6 +++ drivers/usb/musb/omap2430.c | 15 ++++++- drivers/usb/musb/tusb6010.c | 26 +++++++++-- 14 files changed, 311 insertions(+), 10 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index 4c6cfab52fb..c870b625fbd 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -5,7 +5,7 @@ # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller config USB_MUSB_HDRC - depends on USB && USB_GADGET + depends on (USB || USB_GADGET) depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)) select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) select TWL4030_USB if MACH_OMAP_3430SDP @@ -65,6 +65,79 @@ config USB_MUSB_UX500 endchoice +choice + prompt "Driver Mode" + depends on USB_MUSB_HDRC + help + Dual-Role devices can support both host and peripheral roles, + as well as a the special "OTG Device" role which can switch + between both roles as needed. + +# use USB_MUSB_HDRC_HCD not USB_MUSB_HOST to #ifdef host side support; +# OTG needs both roles, not just USB_MUSB_HOST. +config USB_MUSB_HOST + depends on USB + bool "USB Host" + help + Say Y here if your system supports the USB host role. + If it has a USB "A" (rectangular), "Mini-A" (uncommon), + or "Mini-AB" connector, it supports the host role. + (With a "Mini-AB" connector, you should enable USB OTG.) + +# use USB_GADGET_MUSB_HDRC not USB_MUSB_PERIPHERAL to #ifdef peripheral +# side support ... OTG needs both roles +config USB_MUSB_PERIPHERAL + depends on USB_GADGET + bool "USB Peripheral (gadget stack)" + select USB_GADGET_MUSB_HDRC + help + Say Y here if your system supports the USB peripheral role. + If it has a USB "B" (squarish), "Mini-B", or "Mini-AB" + connector, it supports the peripheral role. + (With a "Mini-AB" connector, you should enable USB OTG.) + +config USB_MUSB_OTG + depends on USB && USB_GADGET && PM && EXPERIMENTAL + bool "Both host and peripheral: USB OTG (On The Go) Device" + select USB_GADGET_MUSB_HDRC + select USB_OTG + help + The most notable feature of USB OTG is support for a + "Dual-Role" device, which can act as either a device + or a host. The initial role choice can be changed + later, when two dual-role devices talk to each other. + + At this writing, the OTG support in this driver is incomplete, + omitting the mandatory HNP or SRP protocols. However, some + of the cable based role switching works. (That is, grounding + the ID pin switches the controller to host mode, while leaving + it floating leaves it in peripheral mode.) + + Select this if your system has a Mini-AB connector, or + to simplify certain kinds of configuration. + + To implement your OTG Targeted Peripherals List (TPL), enable + USB_OTG_WHITELIST and update "drivers/usb/core/otg_whitelist.h" + to match your requirements. + +endchoice + +# enable peripheral support (including with OTG) +config USB_GADGET_MUSB_HDRC + bool + depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) +# default y +# select USB_GADGET_DUALSPEED +# select USB_GADGET_SELECTED + +# enables host support (including with OTG) +config USB_MUSB_HDRC_HCD + bool + depends on USB_MUSB_HDRC && (USB_MUSB_HOST || USB_MUSB_OTG) + select USB_OTG if USB_GADGET_MUSB_HDRC + default y + + config MUSB_PIO_ONLY bool 'Disable DMA (always use PIO)' depends on USB_MUSB_HDRC diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index d8fd9d092de..c4d228b6ef8 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o musb_hdrc-y := musb_core.o -musb_hdrc-y += musb_gadget_ep0.o musb_gadget.o -musb_hdrc-y += musb_virthub.o musb_host.o +musb_hdrc-$(CONFIG_USB_GADGET_MUSB_HDRC) += musb_gadget_ep0.o musb_gadget.o +musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) += musb_virthub.o musb_host.o musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o # Hardware Glue Layer diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index e233d2b7d33..d805a69d3c1 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -125,7 +125,11 @@ static void am35x_musb_disable(struct musb *musb) musb_writel(reg_base, USB_END_OF_INTR_REG, 0); } +#ifdef CONFIG_USB_MUSB_HDRC_HCD #define portstate(stmt) stmt +#else +#define portstate(stmt) +#endif static void am35x_musb_set_vbus(struct musb *musb, int is_on) { diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h index c84dae546dc..bd9352a2ef2 100644 --- a/drivers/usb/musb/blackfin.h +++ b/drivers/usb/musb/blackfin.h @@ -47,7 +47,7 @@ * So, need to either use silicon v0.2+ or disable DMA mode in MUSB. */ #if ANOMALY_05000380 && defined(CONFIG_BF52x) && \ - !defined(CONFIG_MUSB_PIO_ONLY) + defined(CONFIG_USB_MUSB_HDRC) && !defined(CONFIG_MUSB_PIO_ONLY) # error "Please use PIO mode in MUSB driver on bf52x chip v0.0 and v0.1" #endif diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 2613bfdb09b..4ba5e185276 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -173,7 +173,11 @@ static void da8xx_musb_disable(struct musb *musb) musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0); } -#define portstate(stmt) stmt +#ifdef CONFIG_USB_MUSB_HDRC_HCD +#define portstate(stmt) stmt +#else +#define portstate(stmt) +#endif static void da8xx_musb_set_vbus(struct musb *musb, int is_on) { @@ -394,15 +398,21 @@ static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode) cfgchip2 &= ~CFGCHIP2_OTGMODE; switch (musb_mode) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD case MUSB_HOST: /* Force VBUS valid, ID = 0 */ cfgchip2 |= CFGCHIP2_FORCE_HOST; break; +#endif +#ifdef CONFIG_USB_GADGET_MUSB_HDRC case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */ cfgchip2 |= CFGCHIP2_FORCE_DEVICE; break; +#endif +#ifdef CONFIG_USB_MUSB_OTG case MUSB_OTG: /* Don't override the VBUS/ID comparators */ cfgchip2 |= CFGCHIP2_NO_OVERRIDE; break; +#endif default: dev_dbg(musb->controller, "Trying to set unsupported mode %u\n", musb_mode); } diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index f9a3f62a83b..2ebdc01d044 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -143,7 +143,12 @@ static void davinci_musb_disable(struct musb *musb) } +#ifdef CONFIG_USB_MUSB_HDRC_HCD #define portstate(stmt) stmt +#else +#define portstate(stmt) +#endif + /* * VBUS SWITCHING IS BOARD-SPECIFIC ... at least for the DM6446 EVM, diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 426cbd86fc1..3279115a8b3 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -328,6 +328,8 @@ void musb_load_testpacket(struct musb *musb) /*-------------------------------------------------------------------------*/ +#ifdef CONFIG_USB_MUSB_OTG + /* * Handles OTG hnp timeouts, such as b_ase0_brst */ @@ -399,6 +401,8 @@ void musb_hnp_stop(struct musb *musb) musb->port1_status &= ~(USB_PORT_STAT_C_CONNECTION << 16); } +#endif + /* * Interrupt Service Routine to record USB "global" interrupts. * Since these do not happen often and signify things of @@ -428,6 +432,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, dev_dbg(musb->controller, "RESUME (%s)\n", otg_state_string(musb->xceiv->state)); if (devctl & MUSB_DEVCTL_HM) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD void __iomem *mbase = musb->mregs; switch (musb->xceiv->state) { @@ -467,13 +472,17 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, "host", otg_state_string(musb->xceiv->state)); } +#endif } else { switch (musb->xceiv->state) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_SUSPEND: /* possibly DISCONNECT is upcoming */ musb->xceiv->state = OTG_STATE_A_HOST; usb_hcd_resume_root_hub(musb_to_hcd(musb)); break; +#endif +#ifdef CONFIG_USB_GADGET_MUSB_HDRC case OTG_STATE_B_WAIT_ACON: case OTG_STATE_B_PERIPHERAL: /* disconnect while suspended? we may @@ -491,6 +500,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, case OTG_STATE_B_IDLE: musb->int_usb &= ~MUSB_INTR_SUSPEND; break; +#endif default: WARNING("bogus %s RESUME (%s)\n", "peripheral", @@ -499,6 +509,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, } } +#ifdef CONFIG_USB_MUSB_HDRC_HCD /* see manual for the order of the tests */ if (int_usb & MUSB_INTR_SESSREQ) { void __iomem *mbase = musb->mregs; @@ -598,12 +609,14 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, handled = IRQ_HANDLED; } +#endif if (int_usb & MUSB_INTR_SUSPEND) { dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x power %02x\n", otg_state_string(musb->xceiv->state), devctl, power); handled = IRQ_HANDLED; switch (musb->xceiv->state) { +#ifdef CONFIG_USB_MUSB_OTG case OTG_STATE_A_PERIPHERAL: /* We also come here if the cable is removed, since * this silicon doesn't report ID-no-longer-grounded. @@ -620,6 +633,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ? : OTG_TIME_A_WAIT_BCON)); break; +#endif case OTG_STATE_B_IDLE: if (!musb->is_active) break; @@ -628,11 +642,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb->is_active = is_otg_enabled(musb) && musb->xceiv->gadget->b_hnp_enable; if (musb->is_active) { +#ifdef CONFIG_USB_MUSB_OTG musb->xceiv->state = OTG_STATE_B_WAIT_ACON; dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); mod_timer(&musb->otg_timer, jiffies + msecs_to_jiffies( OTG_TIME_B_ASE0_BRST)); +#endif } break; case OTG_STATE_A_WAIT_BCON: @@ -656,6 +672,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, } } +#ifdef CONFIG_USB_MUSB_HDRC_HCD if (int_usb & MUSB_INTR_CONNECT) { struct usb_hcd *hcd = musb_to_hcd(musb); @@ -665,6 +682,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb->ep0_stage = MUSB_EP0_START; +#ifdef CONFIG_USB_MUSB_OTG /* flush endpoints when transitioning from Device Mode */ if (is_peripheral_active(musb)) { /* REVISIT HNP; just force disconnect */ @@ -672,6 +690,7 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb_writew(musb->mregs, MUSB_INTRTXE, musb->epmask); musb_writew(musb->mregs, MUSB_INTRRXE, musb->epmask & 0xfffe); musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7); +#endif musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED |USB_PORT_STAT_HIGH_SPEED |USB_PORT_STAT_ENABLE @@ -720,6 +739,7 @@ b_host: dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n", otg_state_string(musb->xceiv->state), devctl); } +#endif /* CONFIG_USB_MUSB_HDRC_HCD */ if ((int_usb & MUSB_INTR_DISCONNECT) && !musb->ignore_disconnect) { dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n", @@ -728,6 +748,7 @@ b_host: handled = IRQ_HANDLED; switch (musb->xceiv->state) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_HOST: case OTG_STATE_A_SUSPEND: usb_hcd_resume_root_hub(musb_to_hcd(musb)); @@ -736,6 +757,8 @@ b_host: musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(musb->a_wait_bcon)); break; +#endif /* HOST */ +#ifdef CONFIG_USB_MUSB_OTG case OTG_STATE_B_HOST: /* REVISIT this behaves for "real disconnect" * cases; make sure the other transitions from @@ -754,10 +777,13 @@ b_host: /* FALLTHROUGH */ case OTG_STATE_B_WAIT_ACON: /* FALLTHROUGH */ +#endif /* OTG */ +#ifdef CONFIG_USB_GADGET_MUSB_HDRC case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_IDLE: musb_g_disconnect(musb); break; +#endif /* GADGET */ default: WARNING("unhandled DISCONNECT transition (%s)\n", otg_state_string(musb->xceiv->state)); @@ -788,6 +814,7 @@ b_host: dev_dbg(musb->controller, "BUS RESET as %s\n", otg_state_string(musb->xceiv->state)); switch (musb->xceiv->state) { +#ifdef CONFIG_USB_OTG case OTG_STATE_A_SUSPEND: /* We need to ignore disconnect on suspend * otherwise tusb 2.0 won't reconnect after a @@ -815,6 +842,7 @@ b_host: musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb_g_reset(musb); break; +#endif case OTG_STATE_B_IDLE: musb->xceiv->state = OTG_STATE_B_PERIPHERAL; /* FALLTHROUGH */ @@ -1167,12 +1195,14 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, /* configure the FIFO */ musb_writeb(mbase, MUSB_INDEX, hw_ep->epnum); +#ifdef CONFIG_USB_MUSB_HDRC_HCD /* EP0 reserved endpoint for control, bidirectional; * EP1 reserved for bulk, two unidirection halves. */ if (hw_ep->epnum == 1) musb->bulk_ep = hw_ep; /* REVISIT error check: be sure ep0 can both rx and tx ... */ +#endif switch (cfg->style) { case FIFO_TX: musb_write_txfifosz(mbase, c_size); @@ -1291,10 +1321,12 @@ done: n + 1, musb->config->num_eps * 2 - 1, offset, (1 << (musb->config->ram_bits + 2))); +#ifdef CONFIG_USB_MUSB_HDRC_HCD if (!musb->bulk_ep) { pr_debug("%s: missing bulk\n", musb_driver_name); return -EINVAL; } +#endif return 0; } @@ -1325,6 +1357,7 @@ static int __init ep_config_from_hw(struct musb *musb) /* FIXME set up hw_ep->{rx,tx}_double_buffered */ +#ifdef CONFIG_USB_MUSB_HDRC_HCD /* pick an RX/TX endpoint for bulk */ if (hw_ep->max_packet_sz_tx < 512 || hw_ep->max_packet_sz_rx < 512) @@ -1336,12 +1369,15 @@ static int __init ep_config_from_hw(struct musb *musb) if (musb->bulk_ep) continue; musb->bulk_ep = hw_ep; +#endif } +#ifdef CONFIG_USB_MUSB_HDRC_HCD if (!musb->bulk_ep) { pr_debug("%s: missing bulk\n", musb_driver_name); return -EINVAL; } +#endif return 0; } @@ -1397,10 +1433,12 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) } else { musb->is_multipoint = 0; type = ""; +#ifdef CONFIG_USB_MUSB_HDRC_HCD #ifndef CONFIG_USB_OTG_BLACKLIST_HUB printk(KERN_ERR "%s: kernel must blacklist external hubs\n", musb_driver_name); +#endif #endif } @@ -1445,9 +1483,11 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) #endif hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase; +#ifdef CONFIG_USB_MUSB_HDRC_HCD hw_ep->target_regs = musb_read_target_reg_base(i, mbase); hw_ep->rx_reinit = 1; hw_ep->tx_reinit = 1; +#endif if (hw_ep->max_packet_sz_tx) { dev_dbg(musb->controller, @@ -1524,6 +1564,14 @@ irqreturn_t musb_interrupt(struct musb *musb) (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral", musb->int_usb, musb->int_tx, musb->int_rx); +#ifdef CONFIG_USB_GADGET_MUSB_HDRC + if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) + if (!musb->gadget_driver) { + dev_dbg(musb->controller, "No gadget driver loaded\n"); + return IRQ_HANDLED; + } +#endif + /* the core can interrupt us for multiple reasons; docs have * a generic interrupt flowchart to follow */ @@ -1722,6 +1770,8 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store); +#ifdef CONFIG_USB_GADGET_MUSB_HDRC + /* Gadget drivers can't know that a host is connected so they might want * to start SRP, but users can. This allows userspace to trigger SRP. */ @@ -1745,10 +1795,14 @@ musb_srp_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store); +#endif /* CONFIG_USB_GADGET_MUSB_HDRC */ + static struct attribute *musb_attributes[] = { &dev_attr_mode.attr, &dev_attr_vbus.attr, +#ifdef CONFIG_USB_GADGET_MUSB_HDRC &dev_attr_srp.attr, +#endif NULL }; @@ -1781,6 +1835,7 @@ allocate_instance(struct device *dev, struct musb *musb; struct musb_hw_ep *ep; int epnum; +#ifdef CONFIG_USB_MUSB_HDRC_HCD struct usb_hcd *hcd; hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev)); @@ -1798,6 +1853,12 @@ allocate_instance(struct device *dev, musb->vbuserr_retry = VBUSERR_RETRY_COUNT; musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON; +#else + musb = kzalloc(sizeof *musb, GFP_KERNEL); + if (!musb) + return NULL; + +#endif dev_set_drvdata(dev, musb); musb->mregs = mbase; musb->ctrl_base = mbase; @@ -1827,7 +1888,9 @@ static void musb_free(struct musb *musb) sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); #endif +#ifdef CONFIG_USB_GADGET_MUSB_HDRC musb_gadget_cleanup(musb); +#endif if (musb->nIrq >= 0) { if (musb->irq_wake) @@ -1841,7 +1904,11 @@ static void musb_free(struct musb *musb) dma_controller_destroy(c); } +#ifdef CONFIG_USB_MUSB_HDRC_HCD + usb_put_hcd(musb_to_hcd(musb)); +#else kfree(musb); +#endif } /* @@ -1935,7 +2002,9 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) if (status < 0) goto fail3; +#ifdef CONFIG_USB_MUSB_OTG setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb); +#endif /* Init IRQ workqueue before request_irq */ INIT_WORK(&musb->irq_work, musb_irq_work); @@ -2370,13 +2439,34 @@ static struct platform_driver musb_driver = { static int __init musb_init(void) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD if (usb_disabled()) return 0; +#endif pr_info("%s: version " MUSB_VERSION ", " +#ifdef CONFIG_MUSB_PIO_ONLY + "pio" +#elif defined(CONFIG_USB_TI_CPPI_DMA) + "cppi-dma" +#elif defined(CONFIG_USB_INVENTRA_DMA) + "musb-dma" +#elif defined(CONFIG_USB_TUSB_OMAP_DMA) + "tusb-omap-dma" +#elif defined(CONFIG_USB_UX500_DMA) + "ux500-dma" +#else "?dma?" +#endif ", " - "otg (peripheral+host)", +#ifdef CONFIG_USB_MUSB_OTG + "otg (peripheral+host)" +#elif defined(CONFIG_USB_GADGET_MUSB_HDRC) + "peripheral" +#elif defined(CONFIG_USB_MUSB_HDRC_HCD) + "host" +#endif + , musb_driver_name); return platform_driver_probe(&musb_driver, musb_probe); } diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index b3c065ab9db..39b4feb248b 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -72,6 +72,10 @@ struct musb_ep; #include #include "musb_host.h" + + +#ifdef CONFIG_USB_MUSB_OTG + #define is_peripheral_enabled(musb) ((musb)->board_mode != MUSB_HOST) #define is_host_enabled(musb) ((musb)->board_mode != MUSB_PERIPHERAL) #define is_otg_enabled(musb) ((musb)->board_mode == MUSB_OTG) @@ -82,6 +86,24 @@ struct musb_ep; #define is_peripheral_active(m) (!(m)->is_host) #define is_host_active(m) ((m)->is_host) +#else +#define is_peripheral_enabled(musb) is_peripheral_capable() +#define is_host_enabled(musb) is_host_capable() +#define is_otg_enabled(musb) 0 + +#define is_peripheral_active(musb) is_peripheral_capable() +#define is_host_active(musb) is_host_capable() +#endif + +#if defined(CONFIG_USB_MUSB_OTG) || defined(CONFIG_USB_MUSB_PERIPHERAL) +/* for some reason, the "select USB_GADGET_MUSB_HDRC" doesn't always + * override that choice selection (often USB_GADGET_DUMMY_HCD). + */ +#ifndef CONFIG_USB_GADGET_MUSB_HDRC +#error bogus Kconfig output ... select CONFIG_USB_GADGET_MUSB_HDRC +#endif +#endif /* need MUSB gadget selection */ + #ifndef CONFIG_HAVE_CLK /* Dummy stub for clk framework */ #define clk_get(dev, id) NULL @@ -97,6 +119,8 @@ struct musb_ep; /****************************** PERIPHERAL ROLE *****************************/ +#ifdef CONFIG_USB_GADGET_MUSB_HDRC + #define is_peripheral_capable() (1) extern irqreturn_t musb_g_ep0_irq(struct musb *); @@ -108,14 +132,40 @@ extern void musb_g_resume(struct musb *); extern void musb_g_wakeup(struct musb *); extern void musb_g_disconnect(struct musb *); +#else + +#define is_peripheral_capable() (0) + +static inline irqreturn_t musb_g_ep0_irq(struct musb *m) { return IRQ_NONE; } +static inline void musb_g_reset(struct musb *m) {} +static inline void musb_g_suspend(struct musb *m) {} +static inline void musb_g_resume(struct musb *m) {} +static inline void musb_g_wakeup(struct musb *m) {} +static inline void musb_g_disconnect(struct musb *m) {} + +#endif + /****************************** HOST ROLE ***********************************/ +#ifdef CONFIG_USB_MUSB_HDRC_HCD + #define is_host_capable() (1) extern irqreturn_t musb_h_ep0_irq(struct musb *); extern void musb_host_tx(struct musb *, u8); extern void musb_host_rx(struct musb *, u8); +#else + +#define is_host_capable() (0) + +static inline irqreturn_t musb_h_ep0_irq(struct musb *m) { return IRQ_NONE; } +static inline void musb_host_tx(struct musb *m, u8 e) {} +static inline void musb_host_rx(struct musb *m, u8 e) {} + +#endif + + /****************************** CONSTANTS ********************************/ #ifndef MUSB_C_NUM_EPS @@ -268,6 +318,7 @@ struct musb_hw_ep { void __iomem *fifo_sync_va; #endif +#ifdef CONFIG_USB_MUSB_HDRC_HCD void __iomem *target_regs; /* currently scheduled peripheral endpoint */ @@ -276,20 +327,31 @@ struct musb_hw_ep { u8 rx_reinit; u8 tx_reinit; +#endif +#ifdef CONFIG_USB_GADGET_MUSB_HDRC /* peripheral side */ struct musb_ep ep_in; /* TX */ struct musb_ep ep_out; /* RX */ +#endif }; static inline struct musb_request *next_in_request(struct musb_hw_ep *hw_ep) { +#ifdef CONFIG_USB_GADGET_MUSB_HDRC return next_request(&hw_ep->ep_in); +#else + return NULL; +#endif } static inline struct musb_request *next_out_request(struct musb_hw_ep *hw_ep) { +#ifdef CONFIG_USB_GADGET_MUSB_HDRC return next_request(&hw_ep->ep_out); +#else + return NULL; +#endif } struct musb_csr_regs { @@ -334,6 +396,7 @@ struct musb { u32 port1_status; +#ifdef CONFIG_USB_MUSB_HDRC_HCD unsigned long rh_timer; enum musb_h_ep0_state ep0_stage; @@ -351,6 +414,7 @@ struct musb { struct list_head out_bulk; /* of musb_qh */ struct timer_list otg_timer; +#endif struct notifier_block nb; struct dma_controller *dma_controller; @@ -412,6 +476,7 @@ struct musb { #define can_bulk_combine(musb,type) \ (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_combine) +#ifdef CONFIG_USB_GADGET_MUSB_HDRC /* is_suspended means USB B_PERIPHERAL suspend */ unsigned is_suspended:1; @@ -435,6 +500,7 @@ struct musb { enum musb_g_ep0_state ep0_state; struct usb_gadget g; /* the gadget */ struct usb_gadget_driver *gadget_driver; /* its driver */ +#endif /* * FIXME: Remove this flag. @@ -456,10 +522,12 @@ struct musb { #endif }; +#ifdef CONFIG_USB_GADGET_MUSB_HDRC static inline struct musb *gadget_to_musb(struct usb_gadget *g) { return container_of(g, struct musb, g); } +#endif #ifdef CONFIG_BLACKFIN static inline int musb_read_fifosize(struct musb *musb, diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 922148ff8d2..0ea413c0597 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -2024,7 +2024,9 @@ static int musb_gadget_stop(struct usb_gadget *g, spin_lock_irqsave(&musb->lock, flags); +#ifdef CONFIG_USB_MUSB_OTG musb_hnp_stop(musb); +#endif (void) musb_gadget_vbus_draw(&musb->g, 0); @@ -2138,6 +2140,7 @@ void musb_g_disconnect(struct musb *musb) switch (musb->xceiv->state) { default: +#ifdef CONFIG_USB_MUSB_OTG dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", otg_state_string(musb->xceiv->state)); musb->xceiv->state = OTG_STATE_A_IDLE; @@ -2149,6 +2152,7 @@ void musb_g_disconnect(struct musb *musb) break; case OTG_STATE_B_WAIT_ACON: case OTG_STATE_B_HOST: +#endif case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_IDLE: musb->xceiv->state = OTG_STATE_B_IDLE; diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 6a0d0467ec7..9bf8ef12fac 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c @@ -88,6 +88,7 @@ static int service_tx_status_request( case USB_RECIP_DEVICE: result[0] = musb->is_self_powered << USB_DEVICE_SELF_POWERED; result[0] |= musb->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; +#ifdef CONFIG_USB_MUSB_OTG if (musb->g.is_otg) { result[0] |= musb->g.b_hnp_enable << USB_DEVICE_B_HNP_ENABLE; @@ -96,6 +97,7 @@ static int service_tx_status_request( result[0] |= musb->g.a_hnp_support << USB_DEVICE_A_HNP_SUPPORT; } +#endif break; case USB_RECIP_INTERFACE: @@ -390,6 +392,7 @@ __acquires(musb->lock) if (handled > 0) musb->test_mode = true; break; +#ifdef CONFIG_USB_MUSB_OTG case USB_DEVICE_B_HNP_ENABLE: if (!musb->g.is_otg) goto stall; @@ -406,6 +409,7 @@ __acquires(musb->lock) goto stall; musb->g.a_alt_hnp_support = 1; break; +#endif case USB_DEVICE_DEBUG_MODE: handled = 0; break; diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 622d09fb9ab..14b00776638 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h @@ -95,6 +95,7 @@ extern const struct hc_driver musb_hc_driver; static inline struct urb *next_urb(struct musb_qh *qh) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD struct list_head *queue; if (!qh) @@ -103,6 +104,9 @@ static inline struct urb *next_urb(struct musb_qh *qh) if (list_empty(queue)) return NULL; return list_entry(queue->next, struct urb, urb_list); +#else + return NULL; +#endif } #endif /* _MUSB_HOST_H */ diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index e9f80adc45a..2d80a575883 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -88,12 +88,14 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) OTG_TIME_A_AIDL_BDIS)); musb_platform_try_idle(musb, 0); break; +#ifdef CONFIG_USB_MUSB_OTG case OTG_STATE_B_HOST: musb->xceiv->state = OTG_STATE_B_WAIT_ACON; musb->is_active = is_otg_enabled(musb) && musb->xceiv->host->b_hnp_enable; musb_platform_try_idle(musb, 0); break; +#endif default: dev_dbg(musb->controller, "bogus rh suspend? %s\n", otg_state_string(musb->xceiv->state)); @@ -116,11 +118,13 @@ static void musb_port_reset(struct musb *musb, bool do_reset) u8 power; void __iomem *mbase = musb->mregs; +#ifdef CONFIG_USB_MUSB_OTG if (musb->xceiv->state == OTG_STATE_B_IDLE) { dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n"); musb->port1_status &= ~USB_PORT_STAT_RESET; return; } +#endif if (!is_host_active(musb)) return; @@ -187,12 +191,14 @@ void musb_root_disconnect(struct musb *musb) switch (musb->xceiv->state) { case OTG_STATE_A_SUSPEND: +#ifdef CONFIG_USB_MUSB_OTG if (is_otg_enabled(musb) && musb->xceiv->host->b_hnp_enable) { musb->xceiv->state = OTG_STATE_A_PERIPHERAL; musb->g.is_a_peripheral = 1; break; } +#endif /* FALLTHROUGH */ case OTG_STATE_A_HOST: musb->xceiv->state = OTG_STATE_A_WAIT_BCON; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index ba85f273e48..c5d4c44d0ff 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -51,7 +51,9 @@ static void musb_do_idle(unsigned long _musb) { struct musb *musb = (void *)_musb; unsigned long flags; +#ifdef CONFIG_USB_MUSB_HDRC_HCD u8 power; +#endif u8 devctl; spin_lock_irqsave(&musb->lock, flags); @@ -68,6 +70,7 @@ static void musb_do_idle(unsigned long _musb) MUSB_HST_MODE(musb); } break; +#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_SUSPEND: /* finish RESUME signaling? */ if (musb->port1_status & MUSB_PORT_STAT_RESUME) { @@ -84,12 +87,15 @@ static void musb_do_idle(unsigned long _musb) musb->xceiv->state = OTG_STATE_A_HOST; } break; +#endif +#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_HOST: devctl = musb_readb(musb->mregs, MUSB_DEVCTL); if (devctl & MUSB_DEVCTL_BDEVICE) musb->xceiv->state = OTG_STATE_B_IDLE; else musb->xceiv->state = OTG_STATE_A_WAIT_BCON; +#endif default: break; } @@ -237,11 +243,13 @@ static int musb_otg_notifications(struct notifier_block *nb, dev_dbg(musb->controller, "ID GND\n"); if (is_otg_enabled(musb)) { +#ifdef CONFIG_USB_GADGET_MUSB_HDRC if (musb->gadget_driver) { pm_runtime_get_sync(musb->controller); otg_init(musb->xceiv); omap2430_musb_set_vbus(musb, 1); } +#endif } else { pm_runtime_get_sync(musb->controller); otg_init(musb->xceiv); @@ -252,16 +260,21 @@ static int musb_otg_notifications(struct notifier_block *nb, case USB_EVENT_VBUS: dev_dbg(musb->controller, "VBUS Connect\n"); +#ifdef CONFIG_USB_GADGET_MUSB_HDRC if (musb->gadget_driver) pm_runtime_get_sync(musb->controller); +#endif otg_init(musb->xceiv); break; case USB_EVENT_NONE: dev_dbg(musb->controller, "VBUS Disconnect\n"); +#ifdef CONFIG_USB_GADGET_MUSB_HDRC if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) - if (musb->gadget_driver) { + if (musb->gadget_driver) +#endif + { pm_runtime_mark_last_busy(musb->controller); pm_runtime_put_autosuspend(musb->controller); } diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index ec1480191f7..fc7026d2385 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -270,6 +270,8 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf) static struct musb *the_musb; +#ifdef CONFIG_USB_GADGET_MUSB_HDRC + /* This is used by gadget drivers, and OTG transceiver logic, allowing * at most mA current to be drawn from VBUS during a Default-B session * (that is, while VBUS exceeds 4.4V). In Default-A (including pure host @@ -309,6 +311,10 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) return 0; } +#else +#define tusb_draw_power NULL +#endif + /* workaround for issue 13: change clock during chip idle * (to be fixed in rev3 silicon) ... symptoms include disconnect * or looping suspend/resume cycles @@ -435,15 +441,19 @@ static void musb_do_idle(unsigned long _musb) if (is_host_active(musb) && (musb->port1_status >> 16)) goto done; - if (is_peripheral_enabled(musb) && !musb->gadget_driver) { +#ifdef CONFIG_USB_GADGET_MUSB_HDRC + if (is_peripheral_enabled(musb) && !musb->gadget_driver) wakeups = 0; - } else { + else { wakeups = TUSB_PRCM_WHOSTDISCON - | TUSB_PRCM_WBUS + | TUSB_PRCM_WBUS | TUSB_PRCM_WVBUS; if (is_otg_enabled(musb)) wakeups |= TUSB_PRCM_WID; } +#else + wakeups = TUSB_PRCM_WHOSTDISCON | TUSB_PRCM_WBUS; +#endif tusb_allow_idle(musb, wakeups); } done: @@ -601,22 +611,30 @@ static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) switch (musb_mode) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD case MUSB_HOST: /* Disable PHY ID detect, ground ID */ phy_otg_ctrl &= ~TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; dev_conf |= TUSB_DEV_CONF_ID_SEL; dev_conf &= ~TUSB_DEV_CONF_SOFT_ID; break; +#endif + +#ifdef CONFIG_USB_GADGET_MUSB_HDRC case MUSB_PERIPHERAL: /* Disable PHY ID detect, keep ID pull-up on */ phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; dev_conf |= (TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID); break; +#endif + +#ifdef CONFIG_USB_MUSB_OTG case MUSB_OTG: /* Use PHY ID detection */ phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; dev_conf &= ~(TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID); break; +#endif default: dev_dbg(musb->controller, "Trying to set mode %i\n", musb_mode); @@ -667,6 +685,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) /* B-dev state machine: no vbus ~= disconnect */ if ((is_otg_enabled(musb) && !musb->xceiv->default_a) || !is_host_enabled(musb)) { +#ifdef CONFIG_USB_MUSB_HDRC_HCD /* ? musb_root_disconnect(musb); */ musb->port1_status &= ~(USB_PORT_STAT_CONNECTION @@ -675,6 +694,7 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | USB_PORT_STAT_HIGH_SPEED | USB_PORT_STAT_TEST ); +#endif if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) { dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n"); -- cgit v1.2.3 From 21ca9f7303abf7fb599c1be81fa74d700e3df63b Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Tue, 20 Dec 2011 12:42:31 +0100 Subject: Revert "mach-ux500: musb: Now musb is always in OTG mode" This reverts commit ac28162fc038d50e64ff2e81d64046be22533e0f. --- arch/arm/mach-ux500/usb.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c index 1e7c0cc912e..363282eae61 100644 --- a/arch/arm/mach-ux500/usb.c +++ b/arch/arm/mach-ux500/usb.c @@ -105,7 +105,13 @@ static struct musb_hdrc_config musb_hdrc_config = { }; static struct musb_hdrc_platform_data musb_platform_data = { +#if defined(CONFIG_USB_MUSB_OTG) .mode = MUSB_OTG, +#elif defined(CONFIG_USB_MUSB_PERIPHERAL) + .mode = MUSB_PERIPHERAL, +#else /* defined(CONFIG_USB_MUSB_HOST) */ + .mode = MUSB_HOST, +#endif .config = &musb_hdrc_config, .board_data = &musb_board_data, }; -- cgit v1.2.3 From ce4b59b8d57a4ccf8eebe18d17e330cddb3e050e Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Thu, 19 Jan 2012 14:50:19 +0100 Subject: mach-ux500: sdi: Fixing sdi0 access on snowball This patch fix the SD/MMC boot problem on 3.2 (Bug #912302) MMC_CAP_SD_HIGHSPEED is not supported on snowball resulting on initialisation errors. There is no sdi2 on Snowball too. Signed-off-by: Mathieu Poirier Signed-off-by: Fredrik Soderstedt Signed-off-by: Philippe Langlais --- arch/arm/mach-ux500/board-mop500-sdi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-ux500/board-mop500-sdi.c b/arch/arm/mach-ux500/board-mop500-sdi.c index 1c47f60c588..a4c11f494a1 100644 --- a/arch/arm/mach-ux500/board-mop500-sdi.c +++ b/arch/arm/mach-ux500/board-mop500-sdi.c @@ -279,7 +279,8 @@ void __init snowball_sdi_init(void) { u32 periphid = 0x10480180; - mop500_sdi2_data.capabilities |= MMC_CAP_MMC_HIGHSPEED; + /* On Snowball MMC_CAP_SD_HIGHSPEED isn't supported (Hardware issue?) */ + mop500_sdi0_data.capabilities &= ~MMC_CAP_SD_HIGHSPEED; /* On-board eMMC */ db8500_add_sdi4(&mop500_sdi4_data, periphid); -- cgit v1.2.3 From 0105311e0be8f2b0ff76472a9e07c8a47d54df76 Mon Sep 17 00:00:00 2001 From: Gregory Hermant Date: Mon, 9 Jan 2012 16:05:16 +0100 Subject: Add support for the 9100 Li-ION battery and adjust the bkup battery charger parameters Signed-off-by: Gregory Hermant --- arch/arm/mach-ux500/board-mop500-bm.c | 23 +++++++++++++++++++++++ drivers/power/Kconfig | 6 ++++++ drivers/power/ab8500_charger.c | 18 +++++++++++++----- 3 files changed, 42 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-bm.c b/arch/arm/mach-ux500/board-mop500-bm.c index 91fb887d4f5..44f7968f420 100644 --- a/arch/arm/mach-ux500/board-mop500-bm.c +++ b/arch/arm/mach-ux500/board-mop500-bm.c @@ -155,14 +155,29 @@ static const struct battery_type bat_type[] = { .name = POWER_SUPPLY_TECHNOLOGY_UNKNOWN, .resis_high = 0, .resis_low = 0, +#ifdef CONFIG_AB8500_9100_LI_ION_BATTERY + .battery_resistance = 180, + .charge_full_design = 2600, +#else .battery_resistance = 300, .charge_full_design = 612, +#endif .nominal_voltage = 3700, +#ifdef CONFIG_AB8500_9100_LI_ION_BATTERY + .termination_vol = 4150, +#else .termination_vol = 4050, +#endif .termination_curr = 200, +#ifdef CONFIG_AB8500_9100_LI_ION_BATTERY + .recharge_vol = 4130, + .normal_cur_lvl = 520, + .normal_vol_lvl = 4200, +#else .recharge_vol = 3990, .normal_cur_lvl = 400, .normal_vol_lvl = 4100, +#endif .maint_a_cur_lvl = 400, .maint_a_vol_lvl = 4050, .maint_a_chg_timer_h = 60, @@ -399,13 +414,21 @@ struct ab8500_bm_data ab8500_bm_data = { .usb_safety_tmr_h = 4, .bkup_bat_v = BUP_VCH_SEL_2P6V, .bkup_bat_i = BUP_ICH_SEL_150UA, +#ifdef CONFIG_AB8500_9100_LI_ION_BATTERY + .no_maintenance = true, +#else .no_maintenance = false, +#endif #ifdef CONFIG_AB8500_BATTERY_THERM_ON_BATCTRL .adc_therm = ADC_THERM_BATCTRL, #else .adc_therm = ADC_THERM_BATTEMP, #endif +#ifdef CONFIG_AB8500_9100_LI_ION_BATTERY + .chg_unknown_bat = true, +#else .chg_unknown_bat = false, +#endif .enable_overshoot = false, .fg_res = 10, .cap_levels = &cap_levels, diff --git a/drivers/power/Kconfig b/drivers/power/Kconfig index 2e32409a342..1048ae20be5 100644 --- a/drivers/power/Kconfig +++ b/drivers/power/Kconfig @@ -249,6 +249,12 @@ config AB8500_BATTERY_THERM_ON_BATCTRL Say Y to enable battery temperature measurements using thermistor connected on BATCTRL ADC. +config AB8500_9100_LI_ION_BATTERY + bool "Enable support of the 9100 Li-ion battery charging" + depends on AB8500_BM + help + Say Y to enable support of the 9100 Li-ion battery charging. + config AB5500_BM bool "AB5500 Battery Management Driver" depends on AB5500_CORE && AB5500_GPADC && MACH_U5500 diff --git a/drivers/power/ab8500_charger.c b/drivers/power/ab8500_charger.c index 1b827a980ce..a68fabcb563 100644 --- a/drivers/power/ab8500_charger.c +++ b/drivers/power/ab8500_charger.c @@ -28,6 +28,7 @@ #include #include #include +#include /* Charger constants */ #define NO_PW_CONN 0 @@ -2261,11 +2262,18 @@ static int ab8500_charger_init_hw_registers(struct ab8500_charger *di) } /* Backup battery voltage and current */ - ret = abx500_set_register_interruptible(di->dev, - AB8500_RTC, - AB8500_RTC_BACKUP_CHG_REG, - di->bat->bkup_bat_v | - di->bat->bkup_bat_i); + if (machine_is_snowball()) + ret = abx500_set_register_interruptible(di->dev, + AB8500_RTC, + AB8500_RTC_BACKUP_CHG_REG, + BUP_VCH_SEL_3P1V | + BUP_ICH_SEL_150UA); + else + ret = abx500_set_register_interruptible(di->dev, + AB8500_RTC, + AB8500_RTC_BACKUP_CHG_REG, + di->bat->bkup_bat_v | + di->bat->bkup_bat_i); if (ret) { dev_err(di->dev, "failed to setup backup battery charging\n"); goto out; -- cgit v1.2.3 From 16ae518e914e8c48e68711c78af772cad1adbe21 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Thu, 2 Feb 2012 13:57:25 +0100 Subject: Revert "Revert "mach-ux500: musb: Now musb is always in OTG mode"" This reverts commit 21ca9f7303abf7fb599c1be81fa74d700e3df63b. --- arch/arm/mach-ux500/usb.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/arm/mach-ux500/usb.c b/arch/arm/mach-ux500/usb.c index 363282eae61..1e7c0cc912e 100644 --- a/arch/arm/mach-ux500/usb.c +++ b/arch/arm/mach-ux500/usb.c @@ -105,13 +105,7 @@ static struct musb_hdrc_config musb_hdrc_config = { }; static struct musb_hdrc_platform_data musb_platform_data = { -#if defined(CONFIG_USB_MUSB_OTG) .mode = MUSB_OTG, -#elif defined(CONFIG_USB_MUSB_PERIPHERAL) - .mode = MUSB_PERIPHERAL, -#else /* defined(CONFIG_USB_MUSB_HOST) */ - .mode = MUSB_HOST, -#endif .config = &musb_hdrc_config, .board_data = &musb_board_data, }; -- cgit v1.2.3 From 45c6029ec9d7ce8f905b45aad015b07b190a5f6e Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Thu, 2 Feb 2012 13:57:39 +0100 Subject: Revert "Revert "usb: musb: drop a gigantic amount of ifdeferry"" This reverts commit c8a60ba6986b3094176f7c43527004812437e6b1. --- drivers/usb/musb/Kconfig | 75 +------------------------------ drivers/usb/musb/Makefile | 4 +- drivers/usb/musb/am35x.c | 4 -- drivers/usb/musb/blackfin.h | 2 +- drivers/usb/musb/da8xx.c | 12 +---- drivers/usb/musb/davinci.c | 5 --- drivers/usb/musb/musb_core.c | 92 +------------------------------------- drivers/usb/musb/musb_core.h | 68 ---------------------------- drivers/usb/musb/musb_gadget.c | 4 -- drivers/usb/musb/musb_gadget_ep0.c | 4 -- drivers/usb/musb/musb_host.h | 4 -- drivers/usb/musb/musb_virthub.c | 6 --- drivers/usb/musb/omap2430.c | 15 +------ drivers/usb/musb/tusb6010.c | 26 ++--------- 14 files changed, 10 insertions(+), 311 deletions(-) diff --git a/drivers/usb/musb/Kconfig b/drivers/usb/musb/Kconfig index c870b625fbd..4c6cfab52fb 100644 --- a/drivers/usb/musb/Kconfig +++ b/drivers/usb/musb/Kconfig @@ -5,7 +5,7 @@ # (M)HDRC = (Multipoint) Highspeed Dual-Role Controller config USB_MUSB_HDRC - depends on (USB || USB_GADGET) + depends on USB && USB_GADGET depends on (ARM || (BF54x && !BF544) || (BF52x && !BF522 && !BF523)) select NOP_USB_XCEIV if (ARCH_DAVINCI || MACH_OMAP3EVM || BLACKFIN) select TWL4030_USB if MACH_OMAP_3430SDP @@ -65,79 +65,6 @@ config USB_MUSB_UX500 endchoice -choice - prompt "Driver Mode" - depends on USB_MUSB_HDRC - help - Dual-Role devices can support both host and peripheral roles, - as well as a the special "OTG Device" role which can switch - between both roles as needed. - -# use USB_MUSB_HDRC_HCD not USB_MUSB_HOST to #ifdef host side support; -# OTG needs both roles, not just USB_MUSB_HOST. -config USB_MUSB_HOST - depends on USB - bool "USB Host" - help - Say Y here if your system supports the USB host role. - If it has a USB "A" (rectangular), "Mini-A" (uncommon), - or "Mini-AB" connector, it supports the host role. - (With a "Mini-AB" connector, you should enable USB OTG.) - -# use USB_GADGET_MUSB_HDRC not USB_MUSB_PERIPHERAL to #ifdef peripheral -# side support ... OTG needs both roles -config USB_MUSB_PERIPHERAL - depends on USB_GADGET - bool "USB Peripheral (gadget stack)" - select USB_GADGET_MUSB_HDRC - help - Say Y here if your system supports the USB peripheral role. - If it has a USB "B" (squarish), "Mini-B", or "Mini-AB" - connector, it supports the peripheral role. - (With a "Mini-AB" connector, you should enable USB OTG.) - -config USB_MUSB_OTG - depends on USB && USB_GADGET && PM && EXPERIMENTAL - bool "Both host and peripheral: USB OTG (On The Go) Device" - select USB_GADGET_MUSB_HDRC - select USB_OTG - help - The most notable feature of USB OTG is support for a - "Dual-Role" device, which can act as either a device - or a host. The initial role choice can be changed - later, when two dual-role devices talk to each other. - - At this writing, the OTG support in this driver is incomplete, - omitting the mandatory HNP or SRP protocols. However, some - of the cable based role switching works. (That is, grounding - the ID pin switches the controller to host mode, while leaving - it floating leaves it in peripheral mode.) - - Select this if your system has a Mini-AB connector, or - to simplify certain kinds of configuration. - - To implement your OTG Targeted Peripherals List (TPL), enable - USB_OTG_WHITELIST and update "drivers/usb/core/otg_whitelist.h" - to match your requirements. - -endchoice - -# enable peripheral support (including with OTG) -config USB_GADGET_MUSB_HDRC - bool - depends on USB_MUSB_HDRC && (USB_MUSB_PERIPHERAL || USB_MUSB_OTG) -# default y -# select USB_GADGET_DUALSPEED -# select USB_GADGET_SELECTED - -# enables host support (including with OTG) -config USB_MUSB_HDRC_HCD - bool - depends on USB_MUSB_HDRC && (USB_MUSB_HOST || USB_MUSB_OTG) - select USB_OTG if USB_GADGET_MUSB_HDRC - default y - - config MUSB_PIO_ONLY bool 'Disable DMA (always use PIO)' depends on USB_MUSB_HDRC diff --git a/drivers/usb/musb/Makefile b/drivers/usb/musb/Makefile index c4d228b6ef8..d8fd9d092de 100644 --- a/drivers/usb/musb/Makefile +++ b/drivers/usb/musb/Makefile @@ -6,8 +6,8 @@ obj-$(CONFIG_USB_MUSB_HDRC) += musb_hdrc.o musb_hdrc-y := musb_core.o -musb_hdrc-$(CONFIG_USB_GADGET_MUSB_HDRC) += musb_gadget_ep0.o musb_gadget.o -musb_hdrc-$(CONFIG_USB_MUSB_HDRC_HCD) += musb_virthub.o musb_host.o +musb_hdrc-y += musb_gadget_ep0.o musb_gadget.o +musb_hdrc-y += musb_virthub.o musb_host.o musb_hdrc-$(CONFIG_DEBUG_FS) += musb_debugfs.o # Hardware Glue Layer diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index d805a69d3c1..e233d2b7d33 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -125,11 +125,7 @@ static void am35x_musb_disable(struct musb *musb) musb_writel(reg_base, USB_END_OF_INTR_REG, 0); } -#ifdef CONFIG_USB_MUSB_HDRC_HCD #define portstate(stmt) stmt -#else -#define portstate(stmt) -#endif static void am35x_musb_set_vbus(struct musb *musb, int is_on) { diff --git a/drivers/usb/musb/blackfin.h b/drivers/usb/musb/blackfin.h index bd9352a2ef2..c84dae546dc 100644 --- a/drivers/usb/musb/blackfin.h +++ b/drivers/usb/musb/blackfin.h @@ -47,7 +47,7 @@ * So, need to either use silicon v0.2+ or disable DMA mode in MUSB. */ #if ANOMALY_05000380 && defined(CONFIG_BF52x) && \ - defined(CONFIG_USB_MUSB_HDRC) && !defined(CONFIG_MUSB_PIO_ONLY) + !defined(CONFIG_MUSB_PIO_ONLY) # error "Please use PIO mode in MUSB driver on bf52x chip v0.0 and v0.1" #endif diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 4ba5e185276..2613bfdb09b 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -173,11 +173,7 @@ static void da8xx_musb_disable(struct musb *musb) musb_writel(reg_base, DA8XX_USB_END_OF_INTR_REG, 0); } -#ifdef CONFIG_USB_MUSB_HDRC_HCD -#define portstate(stmt) stmt -#else -#define portstate(stmt) -#endif +#define portstate(stmt) stmt static void da8xx_musb_set_vbus(struct musb *musb, int is_on) { @@ -398,21 +394,15 @@ static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode) cfgchip2 &= ~CFGCHIP2_OTGMODE; switch (musb_mode) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD case MUSB_HOST: /* Force VBUS valid, ID = 0 */ cfgchip2 |= CFGCHIP2_FORCE_HOST; break; -#endif -#ifdef CONFIG_USB_GADGET_MUSB_HDRC case MUSB_PERIPHERAL: /* Force VBUS valid, ID = 1 */ cfgchip2 |= CFGCHIP2_FORCE_DEVICE; break; -#endif -#ifdef CONFIG_USB_MUSB_OTG case MUSB_OTG: /* Don't override the VBUS/ID comparators */ cfgchip2 |= CFGCHIP2_NO_OVERRIDE; break; -#endif default: dev_dbg(musb->controller, "Trying to set unsupported mode %u\n", musb_mode); } diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index 2ebdc01d044..f9a3f62a83b 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -143,12 +143,7 @@ static void davinci_musb_disable(struct musb *musb) } -#ifdef CONFIG_USB_MUSB_HDRC_HCD #define portstate(stmt) stmt -#else -#define portstate(stmt) -#endif - /* * VBUS SWITCHING IS BOARD-SPECIFIC ... at least for the DM6446 EVM, diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 3279115a8b3..426cbd86fc1 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -328,8 +328,6 @@ void musb_load_testpacket(struct musb *musb) /*-------------------------------------------------------------------------*/ -#ifdef CONFIG_USB_MUSB_OTG - /* * Handles OTG hnp timeouts, such as b_ase0_brst */ @@ -401,8 +399,6 @@ void musb_hnp_stop(struct musb *musb) musb->port1_status &= ~(USB_PORT_STAT_C_CONNECTION << 16); } -#endif - /* * Interrupt Service Routine to record USB "global" interrupts. * Since these do not happen often and signify things of @@ -432,7 +428,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, dev_dbg(musb->controller, "RESUME (%s)\n", otg_state_string(musb->xceiv->state)); if (devctl & MUSB_DEVCTL_HM) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD void __iomem *mbase = musb->mregs; switch (musb->xceiv->state) { @@ -472,17 +467,13 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, "host", otg_state_string(musb->xceiv->state)); } -#endif } else { switch (musb->xceiv->state) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_SUSPEND: /* possibly DISCONNECT is upcoming */ musb->xceiv->state = OTG_STATE_A_HOST; usb_hcd_resume_root_hub(musb_to_hcd(musb)); break; -#endif -#ifdef CONFIG_USB_GADGET_MUSB_HDRC case OTG_STATE_B_WAIT_ACON: case OTG_STATE_B_PERIPHERAL: /* disconnect while suspended? we may @@ -500,7 +491,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, case OTG_STATE_B_IDLE: musb->int_usb &= ~MUSB_INTR_SUSPEND; break; -#endif default: WARNING("bogus %s RESUME (%s)\n", "peripheral", @@ -509,7 +499,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, } } -#ifdef CONFIG_USB_MUSB_HDRC_HCD /* see manual for the order of the tests */ if (int_usb & MUSB_INTR_SESSREQ) { void __iomem *mbase = musb->mregs; @@ -609,14 +598,12 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, handled = IRQ_HANDLED; } -#endif if (int_usb & MUSB_INTR_SUSPEND) { dev_dbg(musb->controller, "SUSPEND (%s) devctl %02x power %02x\n", otg_state_string(musb->xceiv->state), devctl, power); handled = IRQ_HANDLED; switch (musb->xceiv->state) { -#ifdef CONFIG_USB_MUSB_OTG case OTG_STATE_A_PERIPHERAL: /* We also come here if the cable is removed, since * this silicon doesn't report ID-no-longer-grounded. @@ -633,7 +620,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, ? : OTG_TIME_A_WAIT_BCON)); break; -#endif case OTG_STATE_B_IDLE: if (!musb->is_active) break; @@ -642,13 +628,11 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb->is_active = is_otg_enabled(musb) && musb->xceiv->gadget->b_hnp_enable; if (musb->is_active) { -#ifdef CONFIG_USB_MUSB_OTG musb->xceiv->state = OTG_STATE_B_WAIT_ACON; dev_dbg(musb->controller, "HNP: Setting timer for b_ase0_brst\n"); mod_timer(&musb->otg_timer, jiffies + msecs_to_jiffies( OTG_TIME_B_ASE0_BRST)); -#endif } break; case OTG_STATE_A_WAIT_BCON: @@ -672,7 +656,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, } } -#ifdef CONFIG_USB_MUSB_HDRC_HCD if (int_usb & MUSB_INTR_CONNECT) { struct usb_hcd *hcd = musb_to_hcd(musb); @@ -682,7 +665,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb->ep0_stage = MUSB_EP0_START; -#ifdef CONFIG_USB_MUSB_OTG /* flush endpoints when transitioning from Device Mode */ if (is_peripheral_active(musb)) { /* REVISIT HNP; just force disconnect */ @@ -690,7 +672,6 @@ static irqreturn_t musb_stage0_irq(struct musb *musb, u8 int_usb, musb_writew(musb->mregs, MUSB_INTRTXE, musb->epmask); musb_writew(musb->mregs, MUSB_INTRRXE, musb->epmask & 0xfffe); musb_writeb(musb->mregs, MUSB_INTRUSBE, 0xf7); -#endif musb->port1_status &= ~(USB_PORT_STAT_LOW_SPEED |USB_PORT_STAT_HIGH_SPEED |USB_PORT_STAT_ENABLE @@ -739,7 +720,6 @@ b_host: dev_dbg(musb->controller, "CONNECT (%s) devctl %02x\n", otg_state_string(musb->xceiv->state), devctl); } -#endif /* CONFIG_USB_MUSB_HDRC_HCD */ if ((int_usb & MUSB_INTR_DISCONNECT) && !musb->ignore_disconnect) { dev_dbg(musb->controller, "DISCONNECT (%s) as %s, devctl %02x\n", @@ -748,7 +728,6 @@ b_host: handled = IRQ_HANDLED; switch (musb->xceiv->state) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_HOST: case OTG_STATE_A_SUSPEND: usb_hcd_resume_root_hub(musb_to_hcd(musb)); @@ -757,8 +736,6 @@ b_host: musb_platform_try_idle(musb, jiffies + msecs_to_jiffies(musb->a_wait_bcon)); break; -#endif /* HOST */ -#ifdef CONFIG_USB_MUSB_OTG case OTG_STATE_B_HOST: /* REVISIT this behaves for "real disconnect" * cases; make sure the other transitions from @@ -777,13 +754,10 @@ b_host: /* FALLTHROUGH */ case OTG_STATE_B_WAIT_ACON: /* FALLTHROUGH */ -#endif /* OTG */ -#ifdef CONFIG_USB_GADGET_MUSB_HDRC case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_IDLE: musb_g_disconnect(musb); break; -#endif /* GADGET */ default: WARNING("unhandled DISCONNECT transition (%s)\n", otg_state_string(musb->xceiv->state)); @@ -814,7 +788,6 @@ b_host: dev_dbg(musb->controller, "BUS RESET as %s\n", otg_state_string(musb->xceiv->state)); switch (musb->xceiv->state) { -#ifdef CONFIG_USB_OTG case OTG_STATE_A_SUSPEND: /* We need to ignore disconnect on suspend * otherwise tusb 2.0 won't reconnect after a @@ -842,7 +815,6 @@ b_host: musb->xceiv->state = OTG_STATE_B_PERIPHERAL; musb_g_reset(musb); break; -#endif case OTG_STATE_B_IDLE: musb->xceiv->state = OTG_STATE_B_PERIPHERAL; /* FALLTHROUGH */ @@ -1195,14 +1167,12 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep, /* configure the FIFO */ musb_writeb(mbase, MUSB_INDEX, hw_ep->epnum); -#ifdef CONFIG_USB_MUSB_HDRC_HCD /* EP0 reserved endpoint for control, bidirectional; * EP1 reserved for bulk, two unidirection halves. */ if (hw_ep->epnum == 1) musb->bulk_ep = hw_ep; /* REVISIT error check: be sure ep0 can both rx and tx ... */ -#endif switch (cfg->style) { case FIFO_TX: musb_write_txfifosz(mbase, c_size); @@ -1321,12 +1291,10 @@ done: n + 1, musb->config->num_eps * 2 - 1, offset, (1 << (musb->config->ram_bits + 2))); -#ifdef CONFIG_USB_MUSB_HDRC_HCD if (!musb->bulk_ep) { pr_debug("%s: missing bulk\n", musb_driver_name); return -EINVAL; } -#endif return 0; } @@ -1357,7 +1325,6 @@ static int __init ep_config_from_hw(struct musb *musb) /* FIXME set up hw_ep->{rx,tx}_double_buffered */ -#ifdef CONFIG_USB_MUSB_HDRC_HCD /* pick an RX/TX endpoint for bulk */ if (hw_ep->max_packet_sz_tx < 512 || hw_ep->max_packet_sz_rx < 512) @@ -1369,15 +1336,12 @@ static int __init ep_config_from_hw(struct musb *musb) if (musb->bulk_ep) continue; musb->bulk_ep = hw_ep; -#endif } -#ifdef CONFIG_USB_MUSB_HDRC_HCD if (!musb->bulk_ep) { pr_debug("%s: missing bulk\n", musb_driver_name); return -EINVAL; } -#endif return 0; } @@ -1433,12 +1397,10 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) } else { musb->is_multipoint = 0; type = ""; -#ifdef CONFIG_USB_MUSB_HDRC_HCD #ifndef CONFIG_USB_OTG_BLACKLIST_HUB printk(KERN_ERR "%s: kernel must blacklist external hubs\n", musb_driver_name); -#endif #endif } @@ -1483,11 +1445,9 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb) #endif hw_ep->regs = MUSB_EP_OFFSET(i, 0) + mbase; -#ifdef CONFIG_USB_MUSB_HDRC_HCD hw_ep->target_regs = musb_read_target_reg_base(i, mbase); hw_ep->rx_reinit = 1; hw_ep->tx_reinit = 1; -#endif if (hw_ep->max_packet_sz_tx) { dev_dbg(musb->controller, @@ -1564,14 +1524,6 @@ irqreturn_t musb_interrupt(struct musb *musb) (devctl & MUSB_DEVCTL_HM) ? "host" : "peripheral", musb->int_usb, musb->int_tx, musb->int_rx); -#ifdef CONFIG_USB_GADGET_MUSB_HDRC - if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) - if (!musb->gadget_driver) { - dev_dbg(musb->controller, "No gadget driver loaded\n"); - return IRQ_HANDLED; - } -#endif - /* the core can interrupt us for multiple reasons; docs have * a generic interrupt flowchart to follow */ @@ -1770,8 +1722,6 @@ musb_vbus_show(struct device *dev, struct device_attribute *attr, char *buf) } static DEVICE_ATTR(vbus, 0644, musb_vbus_show, musb_vbus_store); -#ifdef CONFIG_USB_GADGET_MUSB_HDRC - /* Gadget drivers can't know that a host is connected so they might want * to start SRP, but users can. This allows userspace to trigger SRP. */ @@ -1795,14 +1745,10 @@ musb_srp_store(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(srp, 0644, NULL, musb_srp_store); -#endif /* CONFIG_USB_GADGET_MUSB_HDRC */ - static struct attribute *musb_attributes[] = { &dev_attr_mode.attr, &dev_attr_vbus.attr, -#ifdef CONFIG_USB_GADGET_MUSB_HDRC &dev_attr_srp.attr, -#endif NULL }; @@ -1835,7 +1781,6 @@ allocate_instance(struct device *dev, struct musb *musb; struct musb_hw_ep *ep; int epnum; -#ifdef CONFIG_USB_MUSB_HDRC_HCD struct usb_hcd *hcd; hcd = usb_create_hcd(&musb_hc_driver, dev, dev_name(dev)); @@ -1853,12 +1798,6 @@ allocate_instance(struct device *dev, musb->vbuserr_retry = VBUSERR_RETRY_COUNT; musb->a_wait_bcon = OTG_TIME_A_WAIT_BCON; -#else - musb = kzalloc(sizeof *musb, GFP_KERNEL); - if (!musb) - return NULL; - -#endif dev_set_drvdata(dev, musb); musb->mregs = mbase; musb->ctrl_base = mbase; @@ -1888,9 +1827,7 @@ static void musb_free(struct musb *musb) sysfs_remove_group(&musb->controller->kobj, &musb_attr_group); #endif -#ifdef CONFIG_USB_GADGET_MUSB_HDRC musb_gadget_cleanup(musb); -#endif if (musb->nIrq >= 0) { if (musb->irq_wake) @@ -1904,11 +1841,7 @@ static void musb_free(struct musb *musb) dma_controller_destroy(c); } -#ifdef CONFIG_USB_MUSB_HDRC_HCD - usb_put_hcd(musb_to_hcd(musb)); -#else kfree(musb); -#endif } /* @@ -2002,9 +1935,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) if (status < 0) goto fail3; -#ifdef CONFIG_USB_MUSB_OTG setup_timer(&musb->otg_timer, musb_otg_timer_func, (unsigned long) musb); -#endif /* Init IRQ workqueue before request_irq */ INIT_WORK(&musb->irq_work, musb_irq_work); @@ -2439,34 +2370,13 @@ static struct platform_driver musb_driver = { static int __init musb_init(void) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD if (usb_disabled()) return 0; -#endif pr_info("%s: version " MUSB_VERSION ", " -#ifdef CONFIG_MUSB_PIO_ONLY - "pio" -#elif defined(CONFIG_USB_TI_CPPI_DMA) - "cppi-dma" -#elif defined(CONFIG_USB_INVENTRA_DMA) - "musb-dma" -#elif defined(CONFIG_USB_TUSB_OMAP_DMA) - "tusb-omap-dma" -#elif defined(CONFIG_USB_UX500_DMA) - "ux500-dma" -#else "?dma?" -#endif ", " -#ifdef CONFIG_USB_MUSB_OTG - "otg (peripheral+host)" -#elif defined(CONFIG_USB_GADGET_MUSB_HDRC) - "peripheral" -#elif defined(CONFIG_USB_MUSB_HDRC_HCD) - "host" -#endif - , + "otg (peripheral+host)", musb_driver_name); return platform_driver_probe(&musb_driver, musb_probe); } diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 39b4feb248b..b3c065ab9db 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -72,10 +72,6 @@ struct musb_ep; #include #include "musb_host.h" - - -#ifdef CONFIG_USB_MUSB_OTG - #define is_peripheral_enabled(musb) ((musb)->board_mode != MUSB_HOST) #define is_host_enabled(musb) ((musb)->board_mode != MUSB_PERIPHERAL) #define is_otg_enabled(musb) ((musb)->board_mode == MUSB_OTG) @@ -86,24 +82,6 @@ struct musb_ep; #define is_peripheral_active(m) (!(m)->is_host) #define is_host_active(m) ((m)->is_host) -#else -#define is_peripheral_enabled(musb) is_peripheral_capable() -#define is_host_enabled(musb) is_host_capable() -#define is_otg_enabled(musb) 0 - -#define is_peripheral_active(musb) is_peripheral_capable() -#define is_host_active(musb) is_host_capable() -#endif - -#if defined(CONFIG_USB_MUSB_OTG) || defined(CONFIG_USB_MUSB_PERIPHERAL) -/* for some reason, the "select USB_GADGET_MUSB_HDRC" doesn't always - * override that choice selection (often USB_GADGET_DUMMY_HCD). - */ -#ifndef CONFIG_USB_GADGET_MUSB_HDRC -#error bogus Kconfig output ... select CONFIG_USB_GADGET_MUSB_HDRC -#endif -#endif /* need MUSB gadget selection */ - #ifndef CONFIG_HAVE_CLK /* Dummy stub for clk framework */ #define clk_get(dev, id) NULL @@ -119,8 +97,6 @@ struct musb_ep; /****************************** PERIPHERAL ROLE *****************************/ -#ifdef CONFIG_USB_GADGET_MUSB_HDRC - #define is_peripheral_capable() (1) extern irqreturn_t musb_g_ep0_irq(struct musb *); @@ -132,40 +108,14 @@ extern void musb_g_resume(struct musb *); extern void musb_g_wakeup(struct musb *); extern void musb_g_disconnect(struct musb *); -#else - -#define is_peripheral_capable() (0) - -static inline irqreturn_t musb_g_ep0_irq(struct musb *m) { return IRQ_NONE; } -static inline void musb_g_reset(struct musb *m) {} -static inline void musb_g_suspend(struct musb *m) {} -static inline void musb_g_resume(struct musb *m) {} -static inline void musb_g_wakeup(struct musb *m) {} -static inline void musb_g_disconnect(struct musb *m) {} - -#endif - /****************************** HOST ROLE ***********************************/ -#ifdef CONFIG_USB_MUSB_HDRC_HCD - #define is_host_capable() (1) extern irqreturn_t musb_h_ep0_irq(struct musb *); extern void musb_host_tx(struct musb *, u8); extern void musb_host_rx(struct musb *, u8); -#else - -#define is_host_capable() (0) - -static inline irqreturn_t musb_h_ep0_irq(struct musb *m) { return IRQ_NONE; } -static inline void musb_host_tx(struct musb *m, u8 e) {} -static inline void musb_host_rx(struct musb *m, u8 e) {} - -#endif - - /****************************** CONSTANTS ********************************/ #ifndef MUSB_C_NUM_EPS @@ -318,7 +268,6 @@ struct musb_hw_ep { void __iomem *fifo_sync_va; #endif -#ifdef CONFIG_USB_MUSB_HDRC_HCD void __iomem *target_regs; /* currently scheduled peripheral endpoint */ @@ -327,31 +276,20 @@ struct musb_hw_ep { u8 rx_reinit; u8 tx_reinit; -#endif -#ifdef CONFIG_USB_GADGET_MUSB_HDRC /* peripheral side */ struct musb_ep ep_in; /* TX */ struct musb_ep ep_out; /* RX */ -#endif }; static inline struct musb_request *next_in_request(struct musb_hw_ep *hw_ep) { -#ifdef CONFIG_USB_GADGET_MUSB_HDRC return next_request(&hw_ep->ep_in); -#else - return NULL; -#endif } static inline struct musb_request *next_out_request(struct musb_hw_ep *hw_ep) { -#ifdef CONFIG_USB_GADGET_MUSB_HDRC return next_request(&hw_ep->ep_out); -#else - return NULL; -#endif } struct musb_csr_regs { @@ -396,7 +334,6 @@ struct musb { u32 port1_status; -#ifdef CONFIG_USB_MUSB_HDRC_HCD unsigned long rh_timer; enum musb_h_ep0_state ep0_stage; @@ -414,7 +351,6 @@ struct musb { struct list_head out_bulk; /* of musb_qh */ struct timer_list otg_timer; -#endif struct notifier_block nb; struct dma_controller *dma_controller; @@ -476,7 +412,6 @@ struct musb { #define can_bulk_combine(musb,type) \ (((type) == USB_ENDPOINT_XFER_BULK) && (musb)->bulk_combine) -#ifdef CONFIG_USB_GADGET_MUSB_HDRC /* is_suspended means USB B_PERIPHERAL suspend */ unsigned is_suspended:1; @@ -500,7 +435,6 @@ struct musb { enum musb_g_ep0_state ep0_state; struct usb_gadget g; /* the gadget */ struct usb_gadget_driver *gadget_driver; /* its driver */ -#endif /* * FIXME: Remove this flag. @@ -522,12 +456,10 @@ struct musb { #endif }; -#ifdef CONFIG_USB_GADGET_MUSB_HDRC static inline struct musb *gadget_to_musb(struct usb_gadget *g) { return container_of(g, struct musb, g); } -#endif #ifdef CONFIG_BLACKFIN static inline int musb_read_fifosize(struct musb *musb, diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 0ea413c0597..922148ff8d2 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -2024,9 +2024,7 @@ static int musb_gadget_stop(struct usb_gadget *g, spin_lock_irqsave(&musb->lock, flags); -#ifdef CONFIG_USB_MUSB_OTG musb_hnp_stop(musb); -#endif (void) musb_gadget_vbus_draw(&musb->g, 0); @@ -2140,7 +2138,6 @@ void musb_g_disconnect(struct musb *musb) switch (musb->xceiv->state) { default: -#ifdef CONFIG_USB_MUSB_OTG dev_dbg(musb->controller, "Unhandled disconnect %s, setting a_idle\n", otg_state_string(musb->xceiv->state)); musb->xceiv->state = OTG_STATE_A_IDLE; @@ -2152,7 +2149,6 @@ void musb_g_disconnect(struct musb *musb) break; case OTG_STATE_B_WAIT_ACON: case OTG_STATE_B_HOST: -#endif case OTG_STATE_B_PERIPHERAL: case OTG_STATE_B_IDLE: musb->xceiv->state = OTG_STATE_B_IDLE; diff --git a/drivers/usb/musb/musb_gadget_ep0.c b/drivers/usb/musb/musb_gadget_ep0.c index 9bf8ef12fac..6a0d0467ec7 100644 --- a/drivers/usb/musb/musb_gadget_ep0.c +++ b/drivers/usb/musb/musb_gadget_ep0.c @@ -88,7 +88,6 @@ static int service_tx_status_request( case USB_RECIP_DEVICE: result[0] = musb->is_self_powered << USB_DEVICE_SELF_POWERED; result[0] |= musb->may_wakeup << USB_DEVICE_REMOTE_WAKEUP; -#ifdef CONFIG_USB_MUSB_OTG if (musb->g.is_otg) { result[0] |= musb->g.b_hnp_enable << USB_DEVICE_B_HNP_ENABLE; @@ -97,7 +96,6 @@ static int service_tx_status_request( result[0] |= musb->g.a_hnp_support << USB_DEVICE_A_HNP_SUPPORT; } -#endif break; case USB_RECIP_INTERFACE: @@ -392,7 +390,6 @@ __acquires(musb->lock) if (handled > 0) musb->test_mode = true; break; -#ifdef CONFIG_USB_MUSB_OTG case USB_DEVICE_B_HNP_ENABLE: if (!musb->g.is_otg) goto stall; @@ -409,7 +406,6 @@ __acquires(musb->lock) goto stall; musb->g.a_alt_hnp_support = 1; break; -#endif case USB_DEVICE_DEBUG_MODE: handled = 0; break; diff --git a/drivers/usb/musb/musb_host.h b/drivers/usb/musb/musb_host.h index 14b00776638..622d09fb9ab 100644 --- a/drivers/usb/musb/musb_host.h +++ b/drivers/usb/musb/musb_host.h @@ -95,7 +95,6 @@ extern const struct hc_driver musb_hc_driver; static inline struct urb *next_urb(struct musb_qh *qh) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD struct list_head *queue; if (!qh) @@ -104,9 +103,6 @@ static inline struct urb *next_urb(struct musb_qh *qh) if (list_empty(queue)) return NULL; return list_entry(queue->next, struct urb, urb_list); -#else - return NULL; -#endif } #endif /* _MUSB_HOST_H */ diff --git a/drivers/usb/musb/musb_virthub.c b/drivers/usb/musb/musb_virthub.c index 2d80a575883..e9f80adc45a 100644 --- a/drivers/usb/musb/musb_virthub.c +++ b/drivers/usb/musb/musb_virthub.c @@ -88,14 +88,12 @@ static void musb_port_suspend(struct musb *musb, bool do_suspend) OTG_TIME_A_AIDL_BDIS)); musb_platform_try_idle(musb, 0); break; -#ifdef CONFIG_USB_MUSB_OTG case OTG_STATE_B_HOST: musb->xceiv->state = OTG_STATE_B_WAIT_ACON; musb->is_active = is_otg_enabled(musb) && musb->xceiv->host->b_hnp_enable; musb_platform_try_idle(musb, 0); break; -#endif default: dev_dbg(musb->controller, "bogus rh suspend? %s\n", otg_state_string(musb->xceiv->state)); @@ -118,13 +116,11 @@ static void musb_port_reset(struct musb *musb, bool do_reset) u8 power; void __iomem *mbase = musb->mregs; -#ifdef CONFIG_USB_MUSB_OTG if (musb->xceiv->state == OTG_STATE_B_IDLE) { dev_dbg(musb->controller, "HNP: Returning from HNP; no hub reset from b_idle\n"); musb->port1_status &= ~USB_PORT_STAT_RESET; return; } -#endif if (!is_host_active(musb)) return; @@ -191,14 +187,12 @@ void musb_root_disconnect(struct musb *musb) switch (musb->xceiv->state) { case OTG_STATE_A_SUSPEND: -#ifdef CONFIG_USB_MUSB_OTG if (is_otg_enabled(musb) && musb->xceiv->host->b_hnp_enable) { musb->xceiv->state = OTG_STATE_A_PERIPHERAL; musb->g.is_a_peripheral = 1; break; } -#endif /* FALLTHROUGH */ case OTG_STATE_A_HOST: musb->xceiv->state = OTG_STATE_A_WAIT_BCON; diff --git a/drivers/usb/musb/omap2430.c b/drivers/usb/musb/omap2430.c index c5d4c44d0ff..ba85f273e48 100644 --- a/drivers/usb/musb/omap2430.c +++ b/drivers/usb/musb/omap2430.c @@ -51,9 +51,7 @@ static void musb_do_idle(unsigned long _musb) { struct musb *musb = (void *)_musb; unsigned long flags; -#ifdef CONFIG_USB_MUSB_HDRC_HCD u8 power; -#endif u8 devctl; spin_lock_irqsave(&musb->lock, flags); @@ -70,7 +68,6 @@ static void musb_do_idle(unsigned long _musb) MUSB_HST_MODE(musb); } break; -#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_SUSPEND: /* finish RESUME signaling? */ if (musb->port1_status & MUSB_PORT_STAT_RESUME) { @@ -87,15 +84,12 @@ static void musb_do_idle(unsigned long _musb) musb->xceiv->state = OTG_STATE_A_HOST; } break; -#endif -#ifdef CONFIG_USB_MUSB_HDRC_HCD case OTG_STATE_A_HOST: devctl = musb_readb(musb->mregs, MUSB_DEVCTL); if (devctl & MUSB_DEVCTL_BDEVICE) musb->xceiv->state = OTG_STATE_B_IDLE; else musb->xceiv->state = OTG_STATE_A_WAIT_BCON; -#endif default: break; } @@ -243,13 +237,11 @@ static int musb_otg_notifications(struct notifier_block *nb, dev_dbg(musb->controller, "ID GND\n"); if (is_otg_enabled(musb)) { -#ifdef CONFIG_USB_GADGET_MUSB_HDRC if (musb->gadget_driver) { pm_runtime_get_sync(musb->controller); otg_init(musb->xceiv); omap2430_musb_set_vbus(musb, 1); } -#endif } else { pm_runtime_get_sync(musb->controller); otg_init(musb->xceiv); @@ -260,21 +252,16 @@ static int musb_otg_notifications(struct notifier_block *nb, case USB_EVENT_VBUS: dev_dbg(musb->controller, "VBUS Connect\n"); -#ifdef CONFIG_USB_GADGET_MUSB_HDRC if (musb->gadget_driver) pm_runtime_get_sync(musb->controller); -#endif otg_init(musb->xceiv); break; case USB_EVENT_NONE: dev_dbg(musb->controller, "VBUS Disconnect\n"); -#ifdef CONFIG_USB_GADGET_MUSB_HDRC if (is_otg_enabled(musb) || is_peripheral_enabled(musb)) - if (musb->gadget_driver) -#endif - { + if (musb->gadget_driver) { pm_runtime_mark_last_busy(musb->controller); pm_runtime_put_autosuspend(musb->controller); } diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index fc7026d2385..ec1480191f7 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -270,8 +270,6 @@ void musb_read_fifo(struct musb_hw_ep *hw_ep, u16 len, u8 *buf) static struct musb *the_musb; -#ifdef CONFIG_USB_GADGET_MUSB_HDRC - /* This is used by gadget drivers, and OTG transceiver logic, allowing * at most mA current to be drawn from VBUS during a Default-B session * (that is, while VBUS exceeds 4.4V). In Default-A (including pure host @@ -311,10 +309,6 @@ static int tusb_draw_power(struct otg_transceiver *x, unsigned mA) return 0; } -#else -#define tusb_draw_power NULL -#endif - /* workaround for issue 13: change clock during chip idle * (to be fixed in rev3 silicon) ... symptoms include disconnect * or looping suspend/resume cycles @@ -441,19 +435,15 @@ static void musb_do_idle(unsigned long _musb) if (is_host_active(musb) && (musb->port1_status >> 16)) goto done; -#ifdef CONFIG_USB_GADGET_MUSB_HDRC - if (is_peripheral_enabled(musb) && !musb->gadget_driver) + if (is_peripheral_enabled(musb) && !musb->gadget_driver) { wakeups = 0; - else { + } else { wakeups = TUSB_PRCM_WHOSTDISCON - | TUSB_PRCM_WBUS + | TUSB_PRCM_WBUS | TUSB_PRCM_WVBUS; if (is_otg_enabled(musb)) wakeups |= TUSB_PRCM_WID; } -#else - wakeups = TUSB_PRCM_WHOSTDISCON | TUSB_PRCM_WBUS; -#endif tusb_allow_idle(musb, wakeups); } done: @@ -611,30 +601,22 @@ static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) switch (musb_mode) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD case MUSB_HOST: /* Disable PHY ID detect, ground ID */ phy_otg_ctrl &= ~TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; dev_conf |= TUSB_DEV_CONF_ID_SEL; dev_conf &= ~TUSB_DEV_CONF_SOFT_ID; break; -#endif - -#ifdef CONFIG_USB_GADGET_MUSB_HDRC case MUSB_PERIPHERAL: /* Disable PHY ID detect, keep ID pull-up on */ phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; dev_conf |= (TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID); break; -#endif - -#ifdef CONFIG_USB_MUSB_OTG case MUSB_OTG: /* Use PHY ID detection */ phy_otg_ctrl |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; phy_otg_ena |= TUSB_PHY_OTG_CTRL_OTG_ID_PULLUP; dev_conf &= ~(TUSB_DEV_CONF_ID_SEL | TUSB_DEV_CONF_SOFT_ID); break; -#endif default: dev_dbg(musb->controller, "Trying to set mode %i\n", musb_mode); @@ -685,7 +667,6 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) /* B-dev state machine: no vbus ~= disconnect */ if ((is_otg_enabled(musb) && !musb->xceiv->default_a) || !is_host_enabled(musb)) { -#ifdef CONFIG_USB_MUSB_HDRC_HCD /* ? musb_root_disconnect(musb); */ musb->port1_status &= ~(USB_PORT_STAT_CONNECTION @@ -694,7 +675,6 @@ tusb_otg_ints(struct musb *musb, u32 int_src, void __iomem *tbase) | USB_PORT_STAT_HIGH_SPEED | USB_PORT_STAT_TEST ); -#endif if (otg_stat & TUSB_DEV_OTG_STAT_SESS_END) { dev_dbg(musb->controller, "Forcing disconnect (no interrupt)\n"); -- cgit v1.2.3 From cec9eb3f5ebdc2b55d8018259f01d4f3575fa877 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Thu, 2 Feb 2012 13:30:27 +0100 Subject: config: Enable built-in USB_GADGET_MUSB_HDRC to get USB OTG working on U8500 Signed-off-by: Lee Jones Signed-off-by: Philippe Langlais --- arch/arm/configs/u8500_defconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index 491b7b932cc..ef81a73dae9 100755 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -223,7 +223,7 @@ CONFIG_USB_STORAGE=y CONFIG_USB_LIBUSUAL=y CONFIG_USB_GADGET=y CONFIG_USB_GADGET_VBUS_DRAW=500 -CONFIG_USB_GADGET_MUSB_HDRC=m +CONFIG_USB_GADGET_MUSB_HDRC=y CONFIG_USB_ZERO=m CONFIG_USB_ETH=m CONFIG_USB_FILE_STORAGE=m -- cgit v1.2.3 From 557375deba39a72082f1768a68d25f5cf699cae5 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Wed, 8 Feb 2012 16:32:12 -0800 Subject: ux500: Remove keyboard pin definition for snowball MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Interfered with CG2900 Signed-off-by: Benn Pörscke --- arch/arm/mach-ux500/board-mop500-pins.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c index f8e7cd74e3c..da171115533 100644 --- a/arch/arm/mach-ux500/board-mop500-pins.c +++ b/arch/arm/mach-ux500/board-mop500-pins.c @@ -419,7 +419,6 @@ static struct ux500_pin_lookup mop500_pins[] = { PIN_LOOKUP("nmk-i2c.1", &mop500_pins_i2c1), PIN_LOOKUP("nmk-i2c.2", &mop500_pins_i2c2), PIN_LOOKUP("nmk-i2c.3", &mop500_pins_i2c3), - PIN_LOOKUP("ske", &mop500_pins_ske), PIN_LOOKUP("sdi0", &mop500_pins_sdi0), PIN_LOOKUP("sdi1", &mop500_pins_sdi1), PIN_LOOKUP("sdi2", &mop500_pins_sdi2), @@ -428,6 +427,10 @@ static struct ux500_pin_lookup mop500_pins[] = { PIN_LOOKUP("spi2", &mop500_pins_spi2), }; +static struct ux500_pin_lookup mop500_ske_pins[] = { + PIN_LOOKUP("ske", &mop500_pins_ske), +}; + /* * Sleep pin configuration for u8500 platform. * If another HW is used the GPIO's must be configured @@ -930,6 +933,7 @@ void __init mop500_pins_init(void) ARRAY_SIZE(mop500_pins_common)); ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_ske_pins, ARRAY_SIZE(mop500_ske_pins)); switch (pinsfor) { case PINS_FOR_U9500: @@ -971,6 +975,7 @@ void __init hrefv60_pins_init(void) ARRAY_SIZE(mop500_pins_common)); ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_ske_pins, ARRAY_SIZE(mop500_ske_pins)); nmk_config_pins(hrefv60_pins, ARRAY_SIZE(hrefv60_pins)); -- cgit v1.2.3 From 6ce19d710f424e648bcb6e5b3d06b3d37b4c014d Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Wed, 8 Feb 2012 05:28:09 -0800 Subject: pm: context: Fix ASM thumb2 problem Signed-off-by: Philippe Langlais --- arch/arm/mach-ux500/pm/context_arm.S | 50 ++++++++++++++++++++++++++---------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-ux500/pm/context_arm.S b/arch/arm/mach-ux500/pm/context_arm.S index 55e2accc85f..edb894d6a35 100644 --- a/arch/arm/mach-ux500/pm/context_arm.S +++ b/arch/arm/mach-ux500/pm/context_arm.S @@ -46,10 +46,12 @@ ENTRY(context_save_arm_registers) stmfd sp!, {r1, r2, r3, lr} @ Save on stack ldr r1, [r0] @ Read backup stack pointer - stmia r1, {sp, lr}^ @ Store user mode sp and lr +ARM( stmia r1, {sp, lr}^ ) @ Store user mode sp and lr @ registers - add r1, r1, #8 @ Update backup pointer (not +ARM( add r1, r1, #8 ) @ Update backup pointer (not @ done in previous instruction) +THUMB( str sp, [r1], #+4 ) +THUMB( str lr, [r1], #+4 ) mrs r2, cpsr @ Get CPSR SAVE_AND_INCREMENT r2 r1 @ Save CPSR register @@ -67,23 +69,32 @@ ENTRY(context_save_arm_registers) orr r3, r2, #0x11 @ Save FIQ mode registers msr cpsr_cxsf, r3 mrs r3, spsr - stmia r1!, {r3, r8-r14} +ARM( stmia r1!, {r3, r8-r14} ) +THUMB( stmia r1!, {r3, r8-r12, r14} ) +THUMB( str r13, [r1], #+4 ) + orr r3, r2, #0x12 @ Save IRQ mode registers msr cpsr_cxsf, r3 mrs r3, spsr - stmia r1!, {r3, r13, r14} +ARM( stmia r1!, {r3, r13, r14} ) +THUMB( stmia r1!, {r3, r14} ) +THUMB( str r13, [r1], #+4 ) orr r3, r2, #0x17 @ Save abort mode registers + @ common mode registers msr cpsr_cxsf, r3 mrs r3, spsr - stmia r1!, {r3, r13, r14} +ARM( stmia r1!, {r3, r13, r14} ) +THUMB( stmia r1!, {r3, r14} ) +THUMB( str r13, [r1], #+4 ) orr r3, r2, #0x1B @ Save undef mode registers msr cpsr_cxsf, r3 mrs r3, spsr - stmia r1!, {r3, r13, r14} +ARM( stmia r1!, {r3, r13, r14} ) +THUMB( stmia r1!, {r3, r14} ) +THUMB( str r13, [r1], #+4 ) orr r3, r2, #0x13 @ Return to supervisor mode msr cpsr_cxsf, r3 @@ -120,30 +131,41 @@ ENTRY(context_restore_arm_registers) orr r3, r2, #0x1b @ Restore undef mode registers msr cpsr_cxsf, r3 - ldmdb r1!, {r3, r13, r14} +ARM( ldmdb r1!, {r3, r13, r14} ) +THUMB( ldr r13, [r1], #-4 ) +THUMB( ldmdb r1!, {r3, r14} ) msr spsr_cxsf, r3 orr r3, r2, #0x17 @ Restore abort mode registers msr cpsr_cxsf, r3 - ldmdb r1!, {r3, r13, r14} +ARM( ldmdb r1!, {r3, r13, r14} ) +THUMB( ldr r13, [r1], #-4 ) +THUMB( ldmdb r1!, {r3, r14} ) msr spsr_cxsf, r3 orr r3, r2, #0x12 @ Restore IRQ mode registers msr cpsr_cxsf, r3 - ldmdb r1!, {r3, r13, r14} +ARM( ldmdb r1!, {r3, r13, r14} ) +THUMB( ldr r13, [r1], #-4 ) +THUMB( ldmdb r1!, {r3, r14} ) msr spsr_cxsf, r3 orr r3, r2, #0x11 @ Restore FIQ mode registers msr cpsr_cxsf, r3 - ldmdb r1!, {r3, r8-r14} +ARM( ldmdb r1!, {r3, r8-r14} ) +THUMB( ldr r13, [r1], #-4 ) +THUMB( ldmdb r1!, {r3, r8-r12, r14} ) + msr spsr_cxsf, r3 DECREMENT_AND_RESTORE r1 r3 @ Restore cpsr register msr cpsr_cxsf, r3 - ldmdb r1, {sp, lr}^ @ Restore sp and lr registers - sub r1, r1, #8 @ Update backup pointer (not +ARM( ldmdb r1, {sp, lr}^ ) @ Restore sp and lr registers +ARM( sub r1, r1, #8 ) @ Update backup pointer (not @ done in previous instruction) +THUMB( ldr lr, [r1], #-4 ) +THUMB( ldr sp, [r1], #-4 ) str r1, [r0] @ Write backup stack pointer ldmfd sp!, {r1, r2, r3, pc} @ Restore registers and return @@ -312,7 +334,9 @@ wayLoopL1clean: lineLoopL1clean: mov r2, r1, lsl #30 @ TODO: OK to hard-code @ SoC-specific L1 cache details? - add r2, r0, lsl #5 + mov r3, r0, lsl #5 + add r2, r3 +@ add r2, r0, lsl #5 mcr p15, 0, r2, c7, c10, 2 @ Clean cache by set/way add r0, r0, #1 cmp r0, #256 @ TODO: Ok with hard-coded -- cgit v1.2.3 From 0f1eec91f8edb3d516f3449018e0aa145a3fe7c1 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Tue, 14 Feb 2012 07:46:48 +0100 Subject: lsm303dlh: add support for Android early suspend Signed-off-by: Philippe Langlais --- drivers/hwmon/lsm303dlh_a.c | 13 ++++++++++--- drivers/hwmon/lsm303dlh_m.c | 10 ++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/drivers/hwmon/lsm303dlh_a.c b/drivers/hwmon/lsm303dlh_a.c index 65e92dfb0ff..b3cdd587e8d 100644 --- a/drivers/hwmon/lsm303dlh_a.c +++ b/drivers/hwmon/lsm303dlh_a.c @@ -38,6 +38,9 @@ #endif #include +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif #include /* lsm303dlh accelerometer registers */ @@ -198,6 +201,9 @@ struct lsm303dlh_a_data { unsigned char interrupt_configure[2]; unsigned char interrupt_duration[2]; unsigned char interrupt_threshold[2]; +#ifdef CONFIG_HAS_EARLYSUSPEND + struct early_suspend early_suspend; +#endif int device_status; int id; }; @@ -288,6 +294,7 @@ static int lsm303dlh_a_restore(struct lsm303dlh_a_data *ddata) if (ddata->regulator) regulator_enable(ddata->regulator); + /* BDU should be enabled by default/recommened */ reg = ddata->range; reg |= LSM303DLH_A_CR4_BDU_MASK; @@ -1327,9 +1334,9 @@ static struct i2c_driver lsm303dlh_a_driver = { .id_table = lsm303dlh_a_id, .driver = { .name = "lsm303dlh_a", - #if (!defined(CONFIG_HAS_EARLYSUSPEND) && defined(CONFIG_PM)) - .pm = &lsm303dlh_a_dev_pm_ops, - #endif +#if (!defined(CONFIG_HAS_EARLYSUSPEND) && defined(CONFIG_PM)) + .pm = &lsm303dlh_a_dev_pm_ops, +#endif }, }; diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c index 98704dc5a0b..b2a6feb4538 100644 --- a/drivers/hwmon/lsm303dlh_m.c +++ b/drivers/hwmon/lsm303dlh_m.c @@ -39,6 +39,9 @@ #include #include +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif #include /* lsm303dlh magnetometer registers */ @@ -161,6 +164,9 @@ struct lsm303dlh_m_data { unsigned char mode; unsigned char rate; unsigned char range; +#ifdef CONFIG_HAS_EARLYSUSPEND + struct early_suspend early_suspend; +#endif int device_status; }; @@ -884,9 +890,9 @@ static struct i2c_driver lsm303dlh_m_driver = { .id_table = lsm303dlh_m_id, .driver = { .name = "lsm303dlh_m", - #if (!defined(CONFIG_HAS_EARLYSUSPEND) && defined(CONFIG_PM)) +#if (!defined(CONFIG_HAS_EARLYSUSPEND) && defined(CONFIG_PM)) .pm = &lsm303dlh_m_dev_pm_ops, - #endif +#endif }, }; -- cgit v1.2.3 From 6a68a80e23d03e3da031ea93cfab44d73053f349 Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Tue, 14 Feb 2012 07:46:49 +0100 Subject: input: gpio-keys: Disable hw on suspend Disable hw if active when suspending if the hw can't wake the system from suspend. ST-Ericsson Linux next: - ST-Ericsson ID: - ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ieaf2a2022b23782bc19afa152dc5e3fa5a0024ad Signed-off-by: Jonas Aaberg Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/32721 Reviewed-by: Bengt JONSSON --- drivers/input/keyboard/gpio_keys.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index ed1ed469d08..523ef6cd03c 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -42,6 +42,8 @@ struct gpio_keys_drvdata { struct input_dev *input; struct mutex disable_lock; unsigned int n_buttons; + bool enabled; + bool enable_after_suspend; int (*enable)(struct device *dev); void (*disable)(struct device *dev); struct gpio_button_data data[0]; @@ -437,6 +439,7 @@ static int gpio_keys_open(struct input_dev *input) { struct gpio_keys_drvdata *ddata = input_get_drvdata(input); + ddata->enabled = true; return ddata->enable ? ddata->enable(input->dev.parent) : 0; } @@ -446,6 +449,7 @@ static void gpio_keys_close(struct input_dev *input) if (ddata->disable) ddata->disable(input->dev.parent); + ddata->enabled = false; } /* @@ -578,6 +582,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) ddata->n_buttons = pdata->nbuttons; ddata->enable = pdata->enable; ddata->disable = pdata->disable; + ddata->enabled = false; mutex_init(&ddata->disable_lock); platform_set_drvdata(pdev, ddata); @@ -709,6 +714,10 @@ static int gpio_keys_suspend(struct device *dev) enable_irq_wake(irq); } } + } else { + ddata->enable_after_suspend = ddata->enabled; + if (ddata->enabled) + gpio_keys_close(ddata->input); } return 0; @@ -729,6 +738,10 @@ static int gpio_keys_resume(struct device *dev) gpio_keys_report_event(&ddata->data[i]); } + + if (!device_may_wakeup(dev) && ddata->enable_after_suspend) + gpio_keys_open(ddata->input); + input_sync(ddata->input); return 0; -- cgit v1.2.3 From e0078135e80926605eb34625247afb0585193ba1 Mon Sep 17 00:00:00 2001 From: Rabin Vincent Date: Tue, 14 Feb 2012 07:46:50 +0100 Subject: hwmon: lsm303dlh: use regulator_set_optimum_mode() Inform the regulator framework about the current consumption, to be used with DRMS. Note that the current consumption in sleep modes is much lower, but we do not inform the regulator framework about those for now. ST-Ericsson ID: 366715 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I52b9162eead0091595b731e34ebca3bfc4d3d9be Signed-off-by: Rabin Vincent --- drivers/hwmon/lsm303dlh_a.c | 6 ++++++ drivers/hwmon/lsm303dlh_m.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/hwmon/lsm303dlh_a.c b/drivers/hwmon/lsm303dlh_a.c index b3cdd587e8d..aa152ada859 100644 --- a/drivers/hwmon/lsm303dlh_a.c +++ b/drivers/hwmon/lsm303dlh_a.c @@ -1101,6 +1101,12 @@ static int __devinit lsm303dlh_a_probe(struct i2c_client *client, } if (ddata->regulator) { + /* + * 0.83 milliamps typical with magnetic sensor setting ODR = + * 7.5 Hz, Accelerometer sensor ODR = 50 Hz. Double for + * safety. + */ + regulator_set_optimum_mode(ddata->regulator, 830 * 2); regulator_enable(ddata->regulator); ddata->device_status = DEVICE_ON; } diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c index b2a6feb4538..96bd6863d93 100644 --- a/drivers/hwmon/lsm303dlh_m.c +++ b/drivers/hwmon/lsm303dlh_m.c @@ -696,6 +696,12 @@ static int __devinit lsm303dlh_m_probe(struct i2c_client *client, } if (ddata->regulator) { + /* + * 0.83 milliamps typical with magnetic sensor setting ODR = + * 7.5 Hz, Accelerometer sensor ODR = 50 Hz. Double for + * safety. + */ + regulator_set_optimum_mode(ddata->regulator, 830 * 2); regulator_enable(ddata->regulator); ddata->device_status = DEVICE_ON; } -- cgit v1.2.3 From 20dd03e47a8b4ea55ec7e7a825f37c46ba171893 Mon Sep 17 00:00:00 2001 From: Rabin Vincent Date: Tue, 14 Feb 2012 07:46:51 +0100 Subject: hwmon: lsm303dlhc_a: use regulator_set_optimum_mode() ST-Ericsson ID: 366715 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I3fd6e8025e658110505e77c724f6bf9b00f6ce9c Signed-off-by: Rabin Vincent --- drivers/hwmon/lsm303dlhc_a.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/hwmon/lsm303dlhc_a.c b/drivers/hwmon/lsm303dlhc_a.c index 17c74595ff2..1c6d25f9b87 100644 --- a/drivers/hwmon/lsm303dlhc_a.c +++ b/drivers/hwmon/lsm303dlhc_a.c @@ -518,6 +518,11 @@ static int __devinit lsm303dlhc_a_probe(struct i2c_client *client, } if (adata->regulator) { + /* + * 130 microamps typical with magnetic sensor setting ODR = 7.5 + * Hz, Accelerometer sensor ODR = 50 Hz. Double for safety. + */ + regulator_set_optimum_mode(adata->regulator, 130 * 2); regulator_enable(adata->regulator); adata->device_status = DEVICE_ON; } -- cgit v1.2.3 From 6321e7cfbff6e6fa46f122402f3f031b2d4f6dd5 Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:46:52 +0100 Subject: hwmon:(lsm303dlh)enable X, Y and Z axis by default Enable x,y and z axis bits of accelerometer, to read data from x,y and z axis. ST-Ericsson ID: 369951 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:Ie8cdf30c210cd90520914b051c342050a80bf350 Signed-off-by: Naga Radhesh --- drivers/hwmon/lsm303dlh_a.c | 7 ++++++- drivers/hwmon/lsm303dlhc_a.c | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/lsm303dlh_a.c b/drivers/hwmon/lsm303dlh_a.c index aa152ada859..03158c29469 100644 --- a/drivers/hwmon/lsm303dlh_a.c +++ b/drivers/hwmon/lsm303dlh_a.c @@ -842,10 +842,15 @@ static ssize_t lsm303dlh_a_store_mode(struct device *dev, data = lsm303dlh_a_read(ddata, CTRL_REG1, "CTRL_REG1"); + /* + * If chip doesn't get reset during suspend/resume, + * x,y and z axis bits are getting cleared,so set + * these bits to get x,y,z axis data. + */ + data |= LSM303DLH_A_CR1_AXIS_ENABLE; data &= ~LSM303DLH_A_CR1_PM_MASK; ddata->mode = val; - data |= ((val << LSM303DLH_A_CR1_PM_BIT) & LSM303DLH_A_CR1_PM_MASK); error = lsm303dlh_a_write(ddata, CTRL_REG1, data, "CTRL_REG1"); diff --git a/drivers/hwmon/lsm303dlhc_a.c b/drivers/hwmon/lsm303dlhc_a.c index 1c6d25f9b87..a8b1cd95fa9 100644 --- a/drivers/hwmon/lsm303dlhc_a.c +++ b/drivers/hwmon/lsm303dlhc_a.c @@ -400,6 +400,13 @@ static ssize_t lsm303dlhc_a_store_mode(struct device *dev, data = lsm303dlhc_a_read(ddata, CTRL_REG1, "CTRL_REG1"); + /* + * If chip doesn't get reset during suspend/resume, + * x,y and z axis bits are getting cleared,so set + * these bits to get x,y,z data. + */ + data |= LSM303DLHC_A_CR1_AXIS_ENABLE; + data &= ~LSM303DLHC_A_CR1_MODE_MASK; ddata->mode = val; -- cgit v1.2.3 From a9da60fca6b4bb3d57a96a469a5dc2d7d0cb4ac4 Mon Sep 17 00:00:00 2001 From: Anil Kumar Date: Tue, 14 Feb 2012 07:46:53 +0100 Subject: drivers: hwmon: l3g4200d: Provide gyroscope temperature via sysfs Add sysfs interface to read gyroscope temperature ST-Ericsson ID: 371726 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I8fe2fa836c92f927cb70742a06a8b87b0beaec2f Signed-off-by: Anil Kumar --- drivers/hwmon/l3g4200d.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/hwmon/l3g4200d.c b/drivers/hwmon/l3g4200d.c index fcac3afc044..c07baa09595 100644 --- a/drivers/hwmon/l3g4200d.c +++ b/drivers/hwmon/l3g4200d.c @@ -30,6 +30,7 @@ #define CTRL_REG3 0x22 /* CTRL_REG3 */ #define CTRL_REG4 0x23 /* CTRL_REG4 */ #define CTRL_REG5 0x24 /* CTRL_REG5 */ +#define OUT_TEMP 0x26 /* OUT_TEMP */ #define AXISDATA_REG 0x28 @@ -401,6 +402,24 @@ static ssize_t l3g4200d_store_powermode(struct device *dev, return count; } +static ssize_t l3g4200d_show_gyrotemp(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct platform_device *pdev = to_platform_device(dev); + struct l3g4200d_data *ddata = platform_get_drvdata(pdev); + int ret; + + if (ddata->powermode == PM_OFF || + ddata->device_status == DEVICE_SUSPENDED) + return -EINVAL; + + ret = l3g4200d_read(ddata, OUT_TEMP, "OUT_TEMP"); + if (ret < 0) + return ret; + + return sprintf(buf, "%d\n", ret); +} + static DEVICE_ATTR(gyrodata, S_IRUGO, l3g4200d_show_gyrodata, NULL); static DEVICE_ATTR(range, S_IRUGO | S_IWUGO, @@ -412,11 +431,14 @@ static DEVICE_ATTR(datarate, S_IRUGO | S_IWUGO, static DEVICE_ATTR(powermode, S_IRUGO | S_IWUGO, l3g4200d_show_powermode, l3g4200d_store_powermode); +static DEVICE_ATTR(gyrotemp, S_IRUGO, l3g4200d_show_gyrotemp, NULL); + static struct attribute *l3g4200d_attributes[] = { &dev_attr_gyrodata.attr, &dev_attr_range.attr, &dev_attr_datarate.attr, &dev_attr_powermode.attr, + &dev_attr_gyrotemp.attr, NULL }; -- cgit v1.2.3 From ca615709ef2c2162920fdffbd5537ea0ed06264c Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:46:54 +0100 Subject: mach-ux500:Add platform data of sensors for R3UIB Add platform data for R3 UIB for sensors, change platform data for R2UIB for gyroscope ST-Ericsson ID: 374970 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:I3a9d89841d5a746d444ec1c40491787ffef764b7 Signed-off-by: Naga Radhesh --- arch/arm/mach-ux500/board-mop500-cyttsp.c | 56 +++++++++++++++++++++++++++++ arch/arm/mach-ux500/board-mop500-u8500uib.c | 6 ++-- 2 files changed, 59 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-cyttsp.c b/arch/arm/mach-ux500/board-mop500-cyttsp.c index 2aa27ea9b1f..c64f732d7c7 100755 --- a/arch/arm/mach-ux500/board-mop500-cyttsp.c +++ b/arch/arm/mach-ux500/board-mop500-cyttsp.c @@ -15,16 +15,60 @@ #include #include #include +#include +#include #include #include #include #include +#include #include "pins-db8500.h" #include "board-mop500.h" #include "devices-db8500.h" #define NUM_SSP_CLIENTS 10 +/* + * LSM303DLH accelerometer + magnetometer & L3G4200D Gyroscope sensors + */ +static struct lsm303dlh_platform_data __initdata lsm303dlh_pdata_u8500_r3 = { + .name_a = "lsm303dlh.0", + .name_m = "lsm303dlh.1", + .axis_map_x = 1, + .axis_map_y = 0, + .axis_map_z = 2, + .negative_x = 1, + .negative_y = 1, + .negative_z = 1, +}; + +static struct l3g4200d_gyr_platform_data __initdata l3g4200d_pdata_u8500_r3 = { + .name_gyr = "l3g4200d", + .axis_map_x = 0, + .axis_map_y = 1, + .axis_map_z = 2, + .negative_x = 0, + .negative_y = 1, + .negative_z = 1, +}; +static struct i2c_board_info __initdata mop500_i2c2_devices_u8500_r3[] = { + { + /* LSM303DLH Accelerometer */ + I2C_BOARD_INFO("lsm303dlhc_a", 0x19), + .platform_data = &lsm303dlh_pdata_u8500_r3, + }, + { + /* LSM303DLH Magnetometer */ + I2C_BOARD_INFO("lsm303dlh_m", 0x1E), + .platform_data = &lsm303dlh_pdata_u8500_r3, + }, + { + /* L3G4200D Gyroscope */ + I2C_BOARD_INFO("l3g4200d", 0x68), + .platform_data = &l3g4200d_pdata_u8500_r3, + }, +}; + /* cyttsp_gpio_board_init : configures the touch panel. */ static int cyttsp_plat_init(int on) { @@ -219,8 +263,20 @@ void __init mop500_u8500uib_r3_init(void) mop500_cyttsp_init(); db8500_add_spi2(&mop500_spi2_data); nmk_config_pin((GPIO64_GPIO | PIN_INPUT_PULLUP), false); + if (machine_is_hrefv60()) { + lsm303dlh_pdata_u8500_r3.irq_a1 = HREFV60_ACCEL_INT1_GPIO; + lsm303dlh_pdata_u8500_r3.irq_a2 = HREFV60_ACCEL_INT2_GPIO; + lsm303dlh_pdata_u8500_r3.irq_m = HREFV60_MAGNET_DRDY_GPIO; + } else { + lsm303dlh_pdata_u8500_r3.irq_a1 = GPIO_ACCEL_INT1; + lsm303dlh_pdata_u8500_r3.irq_a2 = GPIO_ACCEL_INT2; + lsm303dlh_pdata_u8500_r3.irq_m = GPIO_MAGNET_DRDY; + } mop500_uib_i2c_add(0, mop500_i2c0_devices_u8500, ARRAY_SIZE(mop500_i2c0_devices_u8500)); mop500_uib_i2c_add(0, mop500_i2c0_devices_u8500, ARRAY_SIZE(mop500_i2c0_devices_u8500)); + + mop500_uib_i2c_add(2, mop500_i2c2_devices_u8500_r3, + ARRAY_SIZE(mop500_i2c2_devices_u8500_r3)); } diff --git a/arch/arm/mach-ux500/board-mop500-u8500uib.c b/arch/arm/mach-ux500/board-mop500-u8500uib.c index 20763004c4a..8c3232e3e3f 100644 --- a/arch/arm/mach-ux500/board-mop500-u8500uib.c +++ b/arch/arm/mach-ux500/board-mop500-u8500uib.c @@ -51,11 +51,11 @@ static struct lsm303dlh_platform_data __initdata lsm303dlh_pdata_u8500 = { #ifdef CONFIG_SENSORS_L3G4200D static struct l3g4200d_gyr_platform_data __initdata l3g4200d_pdata_u8500 = { .name_gyr = "l3g4200d", - .axis_map_x = 1, - .axis_map_y = 0, + .axis_map_x = 0, + .axis_map_y = 1, .axis_map_z = 2, .negative_x = 0, - .negative_y = 0, + .negative_y = 1, .negative_z = 1, }; #endif -- cgit v1.2.3 From 8748f46daa55c2a1cff7ca1e70420bbc0225c43f Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:46:55 +0100 Subject: mach-ux500: Invert X,Y co-ordinates of sensors Now display is inverted to position keypad below display for all UIB's,So x,y co-ordinates of sensor need to be inverted to align with display. ST-Ericsson ID: 368097 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:Ia16da65351da3beac541cfe30ddae7092445f804 Signed-off-by: Naga Radhesh --- arch/arm/mach-ux500/board-mop500-cyttsp.c | 8 ++++---- arch/arm/mach-ux500/board-mop500-u8500uib.c | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-cyttsp.c b/arch/arm/mach-ux500/board-mop500-cyttsp.c index c64f732d7c7..ca33dfd86ab 100755 --- a/arch/arm/mach-ux500/board-mop500-cyttsp.c +++ b/arch/arm/mach-ux500/board-mop500-cyttsp.c @@ -37,8 +37,8 @@ static struct lsm303dlh_platform_data __initdata lsm303dlh_pdata_u8500_r3 = { .axis_map_x = 1, .axis_map_y = 0, .axis_map_z = 2, - .negative_x = 1, - .negative_y = 1, + .negative_x = 0, + .negative_y = 0, .negative_z = 1, }; @@ -47,8 +47,8 @@ static struct l3g4200d_gyr_platform_data __initdata l3g4200d_pdata_u8500_r3 = { .axis_map_x = 0, .axis_map_y = 1, .axis_map_z = 2, - .negative_x = 0, - .negative_y = 1, + .negative_x = 1, + .negative_y = 0, .negative_z = 1, }; static struct i2c_board_info __initdata mop500_i2c2_devices_u8500_r3[] = { diff --git a/arch/arm/mach-ux500/board-mop500-u8500uib.c b/arch/arm/mach-ux500/board-mop500-u8500uib.c index 8c3232e3e3f..1399c1bcde4 100644 --- a/arch/arm/mach-ux500/board-mop500-u8500uib.c +++ b/arch/arm/mach-ux500/board-mop500-u8500uib.c @@ -42,8 +42,8 @@ static struct lsm303dlh_platform_data __initdata lsm303dlh_pdata_u8500 = { .axis_map_x = 1, .axis_map_y = 0, .axis_map_z = 2, - .negative_x = 1, - .negative_y = 1, + .negative_x = 0, + .negative_y = 0, .negative_z = 1, }; #endif @@ -54,8 +54,8 @@ static struct l3g4200d_gyr_platform_data __initdata l3g4200d_pdata_u8500 = { .axis_map_x = 0, .axis_map_y = 1, .axis_map_z = 2, - .negative_x = 0, - .negative_y = 1, + .negative_x = 1, + .negative_y = 0, .negative_z = 1, }; #endif -- cgit v1.2.3 From 4c11ec40c9738bceccd4529cb90a2a4e600a80f9 Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:46:56 +0100 Subject: hwmon: add mutex unlock in error cases In some error cases mutexunlock is missed, so add mutex unlock in error cases. ST-Ericsson ID: 371373 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Signed-off-by: Naga Radhesh --- drivers/hwmon/lsm303dlh_a.c | 1 + drivers/hwmon/lsm303dlh_m.c | 1 + drivers/hwmon/lsm303dlhc_a.c | 5 ++++- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/hwmon/lsm303dlh_a.c b/drivers/hwmon/lsm303dlh_a.c index 03158c29469..ec7b5fbc803 100644 --- a/drivers/hwmon/lsm303dlh_a.c +++ b/drivers/hwmon/lsm303dlh_a.c @@ -769,6 +769,7 @@ static ssize_t lsm303dlh_a_store_range(struct device *dev, ddata->shift_adjust = SHIFT_ADJ_8G; break; default: + mutex_unlock(&ddata->lock); return -EINVAL; } diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c index 96bd6863d93..75d22e82e86 100644 --- a/drivers/hwmon/lsm303dlh_m.c +++ b/drivers/hwmon/lsm303dlh_m.c @@ -522,6 +522,7 @@ static ssize_t lsm303dlh_m_store_range(struct device *dev, z_gain = Z_GAIN_8_1; break; default: + mutex_unlock(&ddata->lock); return -EINVAL; } diff --git a/drivers/hwmon/lsm303dlhc_a.c b/drivers/hwmon/lsm303dlhc_a.c index a8b1cd95fa9..8b7e2fe37b9 100644 --- a/drivers/hwmon/lsm303dlhc_a.c +++ b/drivers/hwmon/lsm303dlhc_a.c @@ -314,8 +314,10 @@ static ssize_t lsm303dlhc_a_store_range(struct device *dev, error = lsm303dlhc_a_write(ddata, CTRL_REG4, ddata->range, "CTRL_REG4"); - if (error < 0) + if (error < 0) { + mutex_unlock(&ddata->lock); return error; + } switch (val) { case LSM303DLHC_A_RANGE_2G: @@ -331,6 +333,7 @@ static ssize_t lsm303dlhc_a_store_range(struct device *dev, ddata->shift_adjust = SHIFT_ADJ_16G; break; default: + mutex_unlock(&ddata->lock); return -EINVAL; } -- cgit v1.2.3 From 17231e3a1220ba94af776624bf2e5d0fc64c76e4 Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:46:57 +0100 Subject: lsm303dlh_m: Check for DLHC device to invert y,z Invert y,z co-ordinates as specified in data sheet if device is LSM303DLHC ST-Ericsson ID: 374970 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:I45e706e3f783dd58e02f23d9579f3422ef7fc984 Signed-off-by: Naga Radhesh --- drivers/hwmon/lsm303dlh_m.c | 23 +++++++++++++---------- include/linux/lsm303dlh.h | 2 ++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/hwmon/lsm303dlh_m.c b/drivers/hwmon/lsm303dlh_m.c index 75d22e82e86..af486d23ee1 100644 --- a/drivers/hwmon/lsm303dlh_m.c +++ b/drivers/hwmon/lsm303dlh_m.c @@ -133,6 +133,9 @@ #define DEVICE_ON 1 #define DEVICE_SUSPENDED 2 +/* device CHIP ID defines */ +#define LSM303DLHC_CHIP_ID 51 + /** * struct lsm303dlh_m_data - data structure used by lsm303dlh_m driver * @client: i2c client @@ -340,16 +343,16 @@ static int lsm303dlh_m_xyz_read(struct lsm303dlh_m_data *ddata) ddata->data[2] = (short) (((xyz_data[4]) << 8) | xyz_data[5]); -#ifdef SENSORS_LSM303DLHC - /* - * the out registers are in x, z and y order - * so swap y and z values - */ - temp = ddata->data[1]; - ddata->data[1] = ddata->data[2]; - ddata->data[2] = temp; -#endif - + /* check if chip is DHLC */ + if (ddata->pdata.chip_id == LSM303DLHC_CHIP_ID) { + /* + * the out registers are in x, z and y order + * so swap y and z values + */ + temp = ddata->data[1]; + ddata->data[1] = ddata->data[2]; + ddata->data[2] = temp; + } /* taking orientation of x,y,z axis into account*/ ddata->data[ddata->pdata.axis_map_x] = ddata->pdata.negative_x ? diff --git a/include/linux/lsm303dlh.h b/include/linux/lsm303dlh.h index ad369b1fbd5..a565faa79ba 100644 --- a/include/linux/lsm303dlh.h +++ b/include/linux/lsm303dlh.h @@ -42,6 +42,7 @@ * @negative_x: x axis is orientation, 0 or 1 * @negative_y: y axis is orientation, 0 or 1 * @negative_z: z axis is orientation, 0 or 1 + * @chip_id: to store ID of the LSM chip */ struct lsm303dlh_platform_data { const char *name_a; @@ -55,6 +56,7 @@ struct lsm303dlh_platform_data { u8 negative_x; u8 negative_y; u8 negative_z; + u32 chip_id; }; #endif /* __KERNEL__ */ -- cgit v1.2.3 From b4373ccf679309143d26ac3d148a81dc7c405fa7 Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:46:58 +0100 Subject: u8500_defconfig: set CONFIG_LSM303DLHC to y Add LSM303DLHC in u8500 defconfig ST-Ericsson ID: 374970 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:Ie6cf0571dd7532ba4490cd821ad98692a3517710 Signed-off-by: Naga Radhesh --- arch/arm/configs/u8500_defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index ef81a73dae9..cfda7a86307 100755 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -172,6 +172,7 @@ CONFIG_POWER_SUPPLY=y CONFIG_AB8500_BM=y CONFIG_SENSORS_AB8500=y CONFIG_SENSORS_LSM303DLH=y +CONFIG_SENSORS_LSM303DLHC=y CONFIG_SENSORS_L3G4200D=y CONFIG_WATCHDOG=y CONFIG_U8500_WATCHDOG_DEBUG=y -- cgit v1.2.3 From d7cd9bc76222b86925db2d0ba76a3ffa34219de0 Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Tue, 14 Feb 2012 07:46:59 +0100 Subject: misc: bh1780gli: Fix some obvious short commings Unbalanced regulator handling on error during probe and msleep on times less than 10 ms. ST-Ericsson Linux next: - ST-Ericsson ID: 370799 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ic1080bf38a2f1e1922ec015b305b5a2de3b30f0e Signed-off-by: Jonas Aaberg --- drivers/misc/bh1780gli.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/misc/bh1780gli.c b/drivers/misc/bh1780gli.c index ec303edd94a..3dbbf52a126 100644 --- a/drivers/misc/bh1780gli.c +++ b/drivers/misc/bh1780gli.c @@ -146,7 +146,7 @@ static ssize_t bh1780_store_power_state(struct device *dev, if (val == BH1780_POFF) regulator_disable(ddata->regulator); - msleep(BH1780_PON_DELAY); + mdelay(BH1780_PON_DELAY); ddata->power_state = val; mutex_unlock(&ddata->lock); @@ -202,7 +202,7 @@ static int __devinit bh1780_probe(struct i2c_client *client, ret = bh1780_read(ddata, BH1780_REG_PARTID, "PART ID"); if (ret < 0) { dev_err(&client->dev, "failed to read part ID\n"); - goto put_regulator; + goto disable_regulator; } #ifdef CONFIG_HAS_EARLYSUSPEND ddata->early_suspend.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; @@ -220,13 +220,15 @@ static int __devinit bh1780_probe(struct i2c_client *client, mutex_init(&ddata->lock); ret = sysfs_create_group(&client->dev.kobj, &bh1780_attr_group); - if (ret) + if (ret) { + dev_err(&client->dev, "failed to create sysfs group\n"); goto put_regulator; + } return 0; - -put_regulator: +disable_regulator: regulator_disable(ddata->regulator); +put_regulator: regulator_put(ddata->regulator); free_ddata: kfree(ddata); -- cgit v1.2.3 From 28fadd1a74188da5b3f98a7568298c74e916037d Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Tue, 14 Feb 2012 07:47:00 +0100 Subject: ARM: ux500: sensors: Update with gpio handling Update the gpio-keyboard use of hal and proximity sensors to use the ux500 pin framework. ST-Ericsson Linux next: - ST-Ericsson ID: - ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I409d9734c3995d6cfdfff8c7196624a4f89b3e2d Signed-off-by: Jonas Aaberg --- arch/arm/configs/u8500_defconfig | 1 + arch/arm/mach-ux500/Kconfig | 6 +++++ arch/arm/mach-ux500/board-mop500-pins.c | 42 ++++++++++++++++++++++++--------- arch/arm/mach-ux500/board-mop500.c | 42 +++++++++++++++++++++++++++++++-- 4 files changed, 78 insertions(+), 13 deletions(-) diff --git a/arch/arm/configs/u8500_defconfig b/arch/arm/configs/u8500_defconfig index cfda7a86307..16fc7d572a4 100755 --- a/arch/arm/configs/u8500_defconfig +++ b/arch/arm/configs/u8500_defconfig @@ -30,6 +30,7 @@ CONFIG_DISPLAY_GENERIC_DSI_PRIMARY_VSYNC=y CONFIG_DISPLAY_SONY_ACX424AKP_DSI_PRIMARY=y CONFIG_DISPLAY_AV8100_TERTIARY=y CONFIG_DISPLAY_AV8100_TRIPPLE_BUFFER=y +CONFIG_UX500_GPIO_KEYS=y CONFIG_UX500_SUSPEND=y CONFIG_UX500_SUSPEND_STANDBY=y CONFIG_UX500_SUSPEND_MEM=y diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig index 92a85c202e6..626154fc2e3 100644 --- a/arch/arm/mach-ux500/Kconfig +++ b/arch/arm/mach-ux500/Kconfig @@ -80,6 +80,12 @@ config UX500_DEBUG_UART Choose the UART on which kernel low-level debug messages should be output. +config UX500_GPIO_KEYS + bool "Use gpio-keys for proximity and hal sensors" + depends on KEYBOARD_GPIO + help + Add proximity and hal sensors as a gpio keyboard. + config SENSORS1P_MOP tristate "HAL and Proximity sensors support" depends on REGULATOR && (GPIO_STMPE2401 || GPIO_TC35892) diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c index da171115533..02b804d91ee 100644 --- a/arch/arm/mach-ux500/board-mop500-pins.c +++ b/arch/arm/mach-ux500/board-mop500-pins.c @@ -17,7 +17,7 @@ #include "pins-db8500.h" #include "pins.h" - +#include "board-mop500.h" #include "board-pins-sleep-force.h" enum custom_pin_cfg_t { @@ -160,9 +160,6 @@ static pin_cfg_t hrefv60_pins[] = { /* DiPro Sensor Interface */ GPIO139_GPIO | PIN_INPUT_PULLUP, /* DIPRO_INT */ - /* HAL SWITCH INTERFACE */ - GPIO145_GPIO | PIN_INPUT_PULLDOWN,/* HAL_SW */ - /* Audio Amplifier Interface */ GPIO149_GPIO | PIN_OUTPUT_HIGH, /* VAUDIO_HF_EN, enable MAX8968 */ @@ -176,9 +173,6 @@ static pin_cfg_t hrefv60_pins[] = { GPIO82_GPIO | PIN_INPUT_PULLUP, /* ACC_INT1 */ GPIO83_GPIO | PIN_INPUT_PULLUP, /* ACC_INT2 */ - /* Proximity Sensor */ - GPIO217_GPIO | PIN_INPUT_PULLUP, - /* SD card detect */ GPIO95_GPIO | PIN_INPUT_PULLUP, }; @@ -411,7 +405,19 @@ static UX500_PINS(mop500_pins_spi2, GPIO217_SPI2_CLK | PIN_OUTPUT_LOW, ); -static struct ux500_pin_lookup mop500_pins[] = { +static UX500_PINS(mop500_pins_sensors1p, + GPIO217_GPIO| PIN_INPUT_PULLUP | + PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, + GPIO145_GPIO | PIN_INPUT_PULLDOWN | + PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, +); + +static UX500_PINS(mop500_pins_sensors1p_old, + PIN_CFG_INPUT(GPIO_PROX_SENSOR, GPIO, NOPULL), + PIN_CFG_INPUT(GPIO_HAL_SENSOR, GPIO, NOPULL), +); + +static struct ux500_pin_lookup mop500_runtime_pins[] = { PIN_LOOKUP("mcde-dpi", &mop500_pins_mcde_dpi), PIN_LOOKUP("mcde-tvout", &mop500_pins_mcde_tvout), PIN_LOOKUP("av8100-hdmi", &mop500_pins_mcde_hdmi), @@ -427,6 +433,14 @@ static struct ux500_pin_lookup mop500_pins[] = { PIN_LOOKUP("spi2", &mop500_pins_spi2), }; +static struct ux500_pin_lookup mop500_runtime_pins_v60[] = { + PIN_LOOKUP("gpio-keys.0", &mop500_pins_sensors1p), +}; + +static struct ux500_pin_lookup mop500_runtime_pins_old[] = { + PIN_LOOKUP("gpio-keys.0", &mop500_pins_sensors1p_old), +}; + static struct ux500_pin_lookup mop500_ske_pins[] = { PIN_LOOKUP("ske", &mop500_pins_ske), }; @@ -641,7 +655,9 @@ static pin_cfg_t mop500_pins_common_power_save_bank4[] = { GPIO143_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO144_GPIO | PIN_SLPM_OUTPUT_HIGH | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + /* 145 - HAL sensor (on v60 and later) */ GPIO145_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + GPIO146_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO147_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, @@ -769,7 +785,9 @@ static pin_cfg_t mop500_pins_common_power_save_bank6_href60[] = { GPIO215_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO216_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + /* 217 - Proximity */ GPIO217_GPIO | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, + GPIO218_GPIO | PIN_SLPM_DIR_INPUT | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, GPIO219_GPIO | PIN_SLPM_OUTPUT_LOW | PIN_SLPM_WAKEUP_ENABLE | PIN_SLPM_PDIS_DISABLED, @@ -932,8 +950,9 @@ void __init mop500_pins_init(void) nmk_config_pins(mop500_pins_common, ARRAY_SIZE(mop500_pins_common)); - ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_runtime_pins, ARRAY_SIZE(mop500_runtime_pins)); ux500_pins_add(mop500_ske_pins, ARRAY_SIZE(mop500_ske_pins)); + ux500_pins_add(mop500_runtime_pins_old, ARRAY_SIZE(mop500_runtime_pins_old)); switch (pinsfor) { case PINS_FOR_U9500: @@ -958,7 +977,7 @@ void __init snowball_pins_init(void) nmk_config_pins(mop500_pins_common, ARRAY_SIZE(mop500_pins_common)); - ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_runtime_pins, ARRAY_SIZE(mop500_runtime_pins)); nmk_config_pins(u8500_pins, ARRAY_SIZE(u8500_pins)); @@ -974,8 +993,9 @@ void __init hrefv60_pins_init(void) nmk_config_pins(mop500_pins_common, ARRAY_SIZE(mop500_pins_common)); - ux500_pins_add(mop500_pins, ARRAY_SIZE(mop500_pins)); + ux500_pins_add(mop500_runtime_pins, ARRAY_SIZE(mop500_runtime_pins)); ux500_pins_add(mop500_ske_pins, ARRAY_SIZE(mop500_ske_pins)); + ux500_pins_add(mop500_runtime_pins_v60, ARRAY_SIZE(mop500_runtime_pins_v60)); nmk_config_pins(hrefv60_pins, ARRAY_SIZE(hrefv60_pins)); diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index ca1677e8b3e..09fe8fcf4be 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -654,6 +654,7 @@ static void __init mop500_i2c_init(void) db8500_add_i2c3(&u8500_i2c3_data); } +#ifdef CONFIG_UX500_GPIO_KEYS static struct gpio_keys_button mop500_gpio_keys[] = { { .desc = "SFH7741 Proximity Sensor", @@ -672,6 +673,7 @@ static struct gpio_keys_button mop500_gpio_keys[] = { }; static struct regulator *sensors1p_regulator; +struct ux500_pins *sensors1p_pins; static int mop500_sensors1p_activate(struct device *dev); static void mop500_sensors1p_deactivate(struct device *dev); @@ -710,6 +712,11 @@ static struct platform_device snowball_gpio_en_3v3_regulator_device = { static int mop500_sensors1p_activate(struct device *dev) { + if (sensors1p_pins == NULL) + return -EINVAL; + + ux500_pins_enable(sensors1p_pins); + sensors1p_regulator = regulator_get(&mop500_gpio_keys_device.dev, "vcc"); if (IS_ERR(sensors1p_regulator)) { @@ -717,15 +724,42 @@ static int mop500_sensors1p_activate(struct device *dev) return PTR_ERR(sensors1p_regulator); } regulator_enable(sensors1p_regulator); + + /* + * Please be aware that the start-up time of the SFH7741 is + * 120 ms and during that time the output is undefined. + */ + return 0; } static void mop500_sensors1p_deactivate(struct device *dev) { - regulator_disable(sensors1p_regulator); - regulator_put(sensors1p_regulator); + if (!IS_ERR(sensors1p_regulator)) { + regulator_disable(sensors1p_regulator); + regulator_put(sensors1p_regulator); + } + + if (sensors1p_pins != NULL) + ux500_pins_disable(sensors1p_pins); } +static __init void mop500_sensors1p_init(void) +{ + sensors1p_pins = ux500_pins_get("gpio-keys.0"); + + if (sensors1p_pins == NULL) { + pr_err("sensors1p: Fail to get keys\n"); + return; + } + + mop500_gpio_keys[0].gpio = PIN_NUM(sensors1p_pins->cfg[0]); + mop500_gpio_keys[1].gpio = PIN_NUM(sensors1p_pins->cfg[1]); +} +#else +static inline void mop500_sensors1p_init(void) { } +#endif + #ifdef CONFIG_LEDS_PWM static struct led_pwm pwm_leds_data[] = { [0] = { @@ -957,7 +991,9 @@ static struct platform_device *mop500_platform_devs[] __initdata = { #ifdef CONFIG_STE_TRACE_MODEM &u8500_trace_modem, #endif +#ifdef CONFIG_UX500_GPIO_KEYS &mop500_gpio_keys_device, +#endif #ifdef CONFIG_LEDS_PWM &ux500_leds_device, #endif @@ -1223,6 +1259,7 @@ static void __init mop500_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif + mop500_sensors1p_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); @@ -1317,6 +1354,7 @@ static void __init hrefv60_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif + mop500_sensors1p_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); -- cgit v1.2.3 From db46426b70b60267d4440811de934fe941964316 Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Tue, 14 Feb 2012 07:47:01 +0100 Subject: ARM: ux500: Remove outdated sensors1p driver Replaced by gpio-keyboard implementation. ST-Ericsson Linux next: - ST-Ericsson ID: - ST-Ericsson FOSS-OUT ID: Trivial Change-Id: Ic6c8ea1d83c4b3d8ad6bbd9aa06ff30213cab6be Signed-off-by: Jonas Aaberg --- arch/arm/mach-ux500/Kconfig | 7 - arch/arm/mach-ux500/Makefile | 1 - arch/arm/mach-ux500/board-mop500.c | 28 --- arch/arm/mach-ux500/include/mach/sensors1p.h | 24 --- arch/arm/mach-ux500/sensors1p.c | 298 --------------------------- 5 files changed, 358 deletions(-) delete mode 100644 arch/arm/mach-ux500/include/mach/sensors1p.h delete mode 100644 arch/arm/mach-ux500/sensors1p.c diff --git a/arch/arm/mach-ux500/Kconfig b/arch/arm/mach-ux500/Kconfig index 626154fc2e3..d26d035bedc 100644 --- a/arch/arm/mach-ux500/Kconfig +++ b/arch/arm/mach-ux500/Kconfig @@ -86,13 +86,6 @@ config UX500_GPIO_KEYS help Add proximity and hal sensors as a gpio keyboard. -config SENSORS1P_MOP - tristate "HAL and Proximity sensors support" - depends on REGULATOR && (GPIO_STMPE2401 || GPIO_TC35892) - help - Add support for Osram's SFH7741 Proximity Sensor and Samsumg - HED54XXU11 HAL Switch - config U5500_MODEM_IRQ bool "Modem IRQ support" depends on UX500_SOC_DB5500 diff --git a/arch/arm/mach-ux500/Makefile b/arch/arm/mach-ux500/Makefile index 70c483b9dd8..625d22081ce 100644 --- a/arch/arm/mach-ux500/Makefile +++ b/arch/arm/mach-ux500/Makefile @@ -24,7 +24,6 @@ obj-$(CONFIG_MACH_U8500) += board-mop500.o board-mop500-sdi.o \ board-mop500-u8500uib.o board-mop500-pins.o \ board-mop500-bm.o \ board-pins-sleep-force.o -obj-$(CONFIG_SENSORS1P_MOP) += sensors1p.o obj-$(CONFIG_MACH_U5500) += board-u5500.o board-u5500-sdi.o \ board-u5500-regulators.o \ board-u5500-pins.o diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 09fe8fcf4be..81484572bcc 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -52,7 +52,6 @@ #include #include #include -#include #ifdef CONFIG_INPUT_AB8500_ACCDET #include #endif @@ -907,30 +906,6 @@ struct platform_device u8500_sim_detect_device = { }; #endif -#ifdef CONFIG_SENSORS1P_MOP -static struct sensors1p_config sensors1p_config = { - /* SFH7741 */ - .proximity = { - .pin = EGPIO_PIN_7, - .startup_time = 120, /* ms */ - .regulator = "v-proximity", - }, - /* HED54XXU11 */ - .hal = { - .pin = EGPIO_PIN_8, - .startup_time = 100, /* Actually, I have no clue. */ - .regulator = "v-hal", - }, -}; - -struct platform_device sensors1p_device = { - .name = "sensors1p", - .dev = { - .platform_data = (void *)&sensors1p_config, - }, -}; -#endif - #ifdef CONFIG_CRYPTO_DEV_UX500 static struct cryp_platform_data u8500_cryp1_platform_data = { .mem_to_engine = { @@ -971,9 +946,6 @@ static struct hash_platform_data u8500_hash1_platform_data = { /* add any platform devices here - TODO */ static struct platform_device *mop500_platform_devs[] __initdata = { -#ifdef CONFIG_SENSORS1P_MOP - &sensors1p_device, -#endif #ifdef CONFIG_U8500_SIM_DETECT &u8500_sim_detect_device, #endif diff --git a/arch/arm/mach-ux500/include/mach/sensors1p.h b/arch/arm/mach-ux500/include/mach/sensors1p.h deleted file mode 100644 index 544e1d8bab5..00000000000 --- a/arch/arm/mach-ux500/include/mach/sensors1p.h +++ /dev/null @@ -1,24 +0,0 @@ - -/* - * Copyright (C) 2009-2010 ST-Ericsson AB - * License terms: GNU General Public License (GPL) version 2 - * Header file for 1 pin gpio sensors; - * Author: Jonas Aaberg - * - */ - -#ifndef __ASM_ARCH_SFH7741_H -#define __ASM_ARCH_SFH7741_H - -struct sensor_config { - int pin; - int startup_time; /* in ms */ - char regulator[32]; -}; - -struct sensors1p_config { - struct sensor_config hal; - struct sensor_config proximity; -}; - -#endif diff --git a/arch/arm/mach-ux500/sensors1p.c b/arch/arm/mach-ux500/sensors1p.c deleted file mode 100644 index e7f4642b1d9..00000000000 --- a/arch/arm/mach-ux500/sensors1p.c +++ /dev/null @@ -1,298 +0,0 @@ - -/* - * Copyright (C) 2009-2010 ST-Ericsson AB - * License terms: GNU General Public License (GPL) version 2 - * Simple userspace interface for - * Proximity Sensor Osram SFH 7741 and HAL switch Samsung HED54XXU11 - * Author: Jonas Aaberg - * - * This driver is only there for making Android happy. It is not ment - * for mainline. - */ - - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -struct sensor { - struct regulator *regulator; - int pin; - int startup_time; - int active; - u64 when_enabled; -}; - -struct sensors1p { - struct sensor hal; - struct sensor proximity; -}; - -static int sensors1p_power_write(struct device *dev, - struct sensor *s, const char *buf) -{ - int val; - - if (sscanf(buf, "%d", &val) != 1) - return -EINVAL; - - if (val != 0 && val != 1) - return -EINVAL; - - if (val != s->active) { - if (val) { - regulator_enable(s->regulator); - s->when_enabled = get_jiffies_64() + - msecs_to_jiffies(s->startup_time); - } else - regulator_disable(s->regulator); - } - s->active = val; - - return strnlen(buf, PAGE_SIZE); - -} - -static ssize_t sensors1p_sysfs_hal_active_set(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) -{ - - - struct sensors1p *s = platform_get_drvdata(container_of(dev, - struct platform_device, - dev)); - return sensors1p_power_write(dev, &s->hal, buf); - -} - -static ssize_t sensors1p_sysfs_proximity_active_set(struct device *dev, - struct device_attribute *attr, - const char *buf, - size_t count) -{ - - - struct sensors1p *s = platform_get_drvdata(container_of(dev, - struct platform_device, - dev)); - return sensors1p_power_write(dev, &s->proximity, buf); - -} - -static ssize_t sensors1p_sysfs_hal_active_get(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct sensors1p *s = platform_get_drvdata(container_of(dev, - struct platform_device, - dev)); - return sprintf(buf, "%d", s->hal.active); -} - -static ssize_t sensors1p_sysfs_proximity_active_get(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct sensors1p *s = platform_get_drvdata(container_of(dev, - struct platform_device, - dev)); - return sprintf(buf, "%d", s->proximity.active); -} - -static int sensors1p_read(struct device *dev, struct sensor *s, char *buf) -{ - int ret; - - if (!s->active) - return -EINVAL; - - /* Only wait if read() is called before the sensor is up and running - * Since jiffies wraps, always sleep maximum time. - */ - if (time_before64(get_jiffies_64(), s->when_enabled)) - mdelay(s->startup_time); - - /* For some odd reason, setting direction in the probe function fails */ - ret = gpio_direction_input(s->pin); - - if (ret) - dev_err(dev, "Failed to set GPIO pin %d to input.\n", s->pin); - else - ret = gpio_get_value(s->pin); - - return sprintf(buf, "%d", ret); -} - -static ssize_t sensors1p_sysfs_hal_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct sensors1p *s = platform_get_drvdata(container_of(dev, - struct platform_device, - dev)); - return sensors1p_read(dev, &s->hal, buf); -} - -static ssize_t sensors1p_sysfs_proximity_show(struct device *dev, - struct device_attribute *attr, - char *buf) -{ - struct sensors1p *s = platform_get_drvdata(container_of(dev, - struct platform_device, - dev)); - return sensors1p_read(dev, &s->proximity, buf); -} - -static DEVICE_ATTR(proximity_activate, 0666, - sensors1p_sysfs_proximity_active_get, - sensors1p_sysfs_proximity_active_set); -static DEVICE_ATTR(hal_activate, 0666, - sensors1p_sysfs_hal_active_get, - sensors1p_sysfs_hal_active_set); -static DEVICE_ATTR(proximity, 0444, sensors1p_sysfs_proximity_show, NULL); -static DEVICE_ATTR(hal, 0444, sensors1p_sysfs_hal_show, NULL); - -static struct attribute *sensors1p_attrs[] = { - &dev_attr_proximity_activate.attr, - &dev_attr_hal_activate.attr, - &dev_attr_proximity.attr, - &dev_attr_hal.attr, - NULL, -}; - -static struct attribute_group sensors1p_attr_group = { - .name = NULL, - .attrs = sensors1p_attrs, -}; - -static int __init sensors1p_probe(struct platform_device *pdev) -{ - int err = -EINVAL; - struct sensors1p_config *c; - struct sensors1p *s = NULL; - - if (!pdev) - goto out; - - c = pdev->dev.platform_data; - - if (c == NULL) { - dev_err(&pdev->dev, "Error: Missconfigured.\n"); - goto out; - } - - s = kzalloc(sizeof(struct sensors1p), GFP_KERNEL); - - if (s == NULL) { - dev_err(&pdev->dev, - "Could not allocate struct memory!\n"); - err = -ENOMEM; - goto out; - } - - s->hal.pin = c->hal.pin; - err = gpio_request(c->hal.pin, "hal sensor"); - if (err < 0) { - dev_err(&pdev->dev, "gpio_request failed with err: %d", err); - goto err_hal_gpio; - } - - s->proximity.pin = c->proximity.pin; - err = gpio_request(c->proximity.pin, "proximity sensor"); - if (err < 0) { - dev_err(&pdev->dev, "gpio_request failed with err: %d", err); - goto err_proximity_gpio; - } - - s->hal.startup_time = c->hal.startup_time; - s->proximity.startup_time = c->proximity.startup_time; - - - s->hal.regulator = regulator_get(&pdev->dev, c->hal.regulator); - - if (IS_ERR(s->hal.regulator)) { - dev_err(&pdev->dev, "regulator_get(\"%s\") failed.\n", - c->hal.regulator); - err = PTR_ERR(s->hal.regulator); - goto err_hal_reg; - } - s->proximity.regulator = regulator_get(&pdev->dev, - c->proximity.regulator); - - if (IS_ERR(s->proximity.regulator)) { - dev_err(&pdev->dev, "regulator_get(\"%s\") failed.\n", - c->proximity.regulator); - err = PTR_ERR(s->proximity.regulator); - goto err_proximity_reg; - } - - err = sysfs_create_group(&pdev->dev.kobj, &sensors1p_attr_group); - - if (err) { - dev_err(&pdev->dev, "Failed to create sysfs entries.\n"); - goto err_sysfs; - } - - platform_set_drvdata(pdev, s); - - return 0; - -err_sysfs: - regulator_put(s->proximity.regulator); -err_proximity_reg: - regulator_put(s->hal.regulator); -err_hal_reg: - gpio_free(s->proximity.pin); -err_proximity_gpio: - gpio_free(s->hal.pin); -err_hal_gpio: - kfree(s); -out: - return err; -} - -static int __exit sensors1p_remove(struct platform_device *pdev) -{ - struct sensors1p *s = platform_get_drvdata(pdev); - - sysfs_remove_group(&pdev->dev.kobj, &sensors1p_attr_group); - gpio_free(s->hal.pin); - gpio_free(s->proximity.pin); - regulator_put(s->hal.regulator); - regulator_put(s->proximity.regulator); - kfree(s); - return 0; -} - -static struct platform_driver sensors1p_driver = { - .remove = __exit_p(sensors1p_remove), - .driver = { - .name = "sensors1p", - .owner = THIS_MODULE, - }, -}; - -static int __init sensors1p_init(void) -{ - return platform_driver_probe(&sensors1p_driver, sensors1p_probe); -} - -static void __exit sensors1p_exit(void) -{ - platform_driver_unregister(&sensors1p_driver); -} - -late_initcall(sensors1p_init); -module_exit(sensors1p_exit); - -MODULE_AUTHOR("Jonas Aaberg "); -MODULE_DESCRIPTION("One pin gpio sensors driver (Proximity+HAL)"); -MODULE_LICENSE("GPLv2"); -- cgit v1.2.3 From 0337d1dcb95937704fd386b1b108c6834e7843c5 Mon Sep 17 00:00:00 2001 From: Jonas Aaberg Date: Tue, 14 Feb 2012 07:47:02 +0100 Subject: ARM: ux500: gpio-keys: Remove dynamic handling of pins Dynamic handling of pins does not work properly if done manually from suspend/resume hooks, so let's remove it for the time beeing. ST-Ericsson Linux next: - ST-Ericsson ID: 369952 ST-Ericsson FOSS-OUT ID: Trivial Change-Id: I3b130256b19af7feae9db0e4a1bd72c7856bb88c Signed-off-by: Jonas Aaberg --- arch/arm/mach-ux500/board-mop500.c | 69 ++++++++++++++------------------------ 1 file changed, 26 insertions(+), 43 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 81484572bcc..8df987925da 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -671,16 +671,15 @@ static struct gpio_keys_button mop500_gpio_keys[] = { } }; -static struct regulator *sensors1p_regulator; -struct ux500_pins *sensors1p_pins; -static int mop500_sensors1p_activate(struct device *dev); -static void mop500_sensors1p_deactivate(struct device *dev); +static struct regulator *gpio_keys_regulator; +static int mop500_gpio_keys_activate(struct device *dev); +static void mop500_gpio_keys_deactivate(struct device *dev); static struct gpio_keys_platform_data mop500_gpio_keys_data = { .buttons = mop500_gpio_keys, .nbuttons = ARRAY_SIZE(mop500_gpio_keys), - .enable = mop500_sensors1p_activate, - .disable = mop500_sensors1p_deactivate, + .enable = mop500_gpio_keys_activate, + .disable = mop500_gpio_keys_deactivate, }; static struct platform_device mop500_gpio_keys_device = { @@ -709,20 +708,15 @@ static struct platform_device snowball_gpio_en_3v3_regulator_device = { }; #endif -static int mop500_sensors1p_activate(struct device *dev) +static int mop500_gpio_keys_activate(struct device *dev) { - if (sensors1p_pins == NULL) - return -EINVAL; - - ux500_pins_enable(sensors1p_pins); - - sensors1p_regulator = regulator_get(&mop500_gpio_keys_device.dev, + gpio_keys_regulator = regulator_get(&mop500_gpio_keys_device.dev, "vcc"); - if (IS_ERR(sensors1p_regulator)) { + if (IS_ERR(gpio_keys_regulator)) { dev_err(&mop500_gpio_keys_device.dev, "no regulator\n"); - return PTR_ERR(sensors1p_regulator); + return PTR_ERR(gpio_keys_regulator); } - regulator_enable(sensors1p_regulator); + regulator_enable(gpio_keys_regulator); /* * Please be aware that the start-up time of the SFH7741 is @@ -732,31 +726,31 @@ static int mop500_sensors1p_activate(struct device *dev) return 0; } -static void mop500_sensors1p_deactivate(struct device *dev) +static void mop500_gpio_keys_deactivate(struct device *dev) { - if (!IS_ERR(sensors1p_regulator)) { - regulator_disable(sensors1p_regulator); - regulator_put(sensors1p_regulator); + if (!IS_ERR(gpio_keys_regulator)) { + regulator_disable(gpio_keys_regulator); + regulator_put(gpio_keys_regulator); } - - if (sensors1p_pins != NULL) - ux500_pins_disable(sensors1p_pins); } -static __init void mop500_sensors1p_init(void) +static __init void mop500_gpio_keys_init(void) { - sensors1p_pins = ux500_pins_get("gpio-keys.0"); + struct ux500_pins *gpio_keys_pins = ux500_pins_get("gpio-keys.0"); - if (sensors1p_pins == NULL) { - pr_err("sensors1p: Fail to get keys\n"); + if (gpio_keys_pins == NULL) { + pr_err("gpio_keys: Fail to get pins\n"); return; } - mop500_gpio_keys[0].gpio = PIN_NUM(sensors1p_pins->cfg[0]); - mop500_gpio_keys[1].gpio = PIN_NUM(sensors1p_pins->cfg[1]); + ux500_pins_enable(gpio_keys_pins); + + mop500_gpio_keys[0].gpio = PIN_NUM(gpio_keys_pins->cfg[0]); + mop500_gpio_keys[1].gpio = PIN_NUM(gpio_keys_pins->cfg[1]); + } #else -static inline void mop500_sensors1p_init(void) { } +static inline void mop500_gpio_keys_init(void) { } #endif #ifdef CONFIG_LEDS_PWM @@ -1217,9 +1211,6 @@ static struct platform_device *snowball_platform_devs[] __initdata = { static void __init mop500_init_machine(void) { - mop500_gpio_keys[0].gpio = GPIO_PROX_SENSOR; - mop500_gpio_keys[1].gpio = GPIO_HAL_SENSOR; - u8500_init_devices(); mop500_pins_init(); @@ -1231,7 +1222,7 @@ static void __init mop500_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif - mop500_sensors1p_init(); + mop500_gpio_keys_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); @@ -1299,14 +1290,6 @@ static void __init snowball_init_machine(void) static void __init hrefv60_init_machine(void) { - /* - * The HREFv60 board removed a GPIO expander and routed - * all these GPIO pins to the internal GPIO controller - * instead. - */ - mop500_gpio_keys[0].gpio = HREFV60_PROX_SENSE_GPIO; - mop500_gpio_keys[1].gpio = HREFV60_HAL_SW_GPIO; - #ifdef CONFIG_INPUT_AB8500_ACCDET /* * On boards hrefpv60 and later, the accessory insertion/removal, @@ -1326,7 +1309,7 @@ static void __init hrefv60_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif - mop500_sensors1p_init(); + mop500_gpio_keys_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); -- cgit v1.2.3 From 9f6c66e59d2ee3224b45d1489e94f3b0d274204e Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:47:03 +0100 Subject: mach-ux500:Configure Proximity GPIO based on UIB Move proximity platform data from board-mop500 to board-mop500-uib and configure the GPIO pin depending on UIB ST-Ericsson ID: 374970 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:Ie61cc1f24ec1c80cb2659eacd7bff6f10e9ccbea Signed-off-by: Naga Radhesh --- arch/arm/mach-ux500/board-mop500-pins.c | 2 + arch/arm/mach-ux500/board-mop500-uib.c | 102 +++++++++++++++++++++++++++++++- arch/arm/mach-ux500/board-mop500.c | 87 --------------------------- 3 files changed, 102 insertions(+), 89 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-pins.c b/arch/arm/mach-ux500/board-mop500-pins.c index 02b804d91ee..96f7b084c73 100644 --- a/arch/arm/mach-ux500/board-mop500-pins.c +++ b/arch/arm/mach-ux500/board-mop500-pins.c @@ -410,6 +410,8 @@ static UX500_PINS(mop500_pins_sensors1p, PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, GPIO145_GPIO | PIN_INPUT_PULLDOWN | PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, + GPIO139_GPIO | PIN_INPUT_PULLUP | + PIN_SLPM_GPIO | PIN_SLPM_INPUT_NOPULL, ); static UX500_PINS(mop500_pins_sensors1p_old, diff --git a/arch/arm/mach-ux500/board-mop500-uib.c b/arch/arm/mach-ux500/board-mop500-uib.c index 8679b15643c..6dc77d42d86 100644 --- a/arch/arm/mach-ux500/board-mop500-uib.c +++ b/arch/arm/mach-ux500/board-mop500-uib.c @@ -11,9 +11,14 @@ #include #include #include -#include #include +#include +#include +#include +#include +#include +#include "pins.h" #include "board-mop500.h" enum mop500_uib { @@ -129,6 +134,97 @@ int uib_is_u8500uibr3(void) return (type_of_uib == U8500UIB_R3); } + +#ifdef CONFIG_UX500_GPIO_KEYS +static struct gpio_keys_button mop500_gpio_keys[] = { + { + .desc = "SFH7741 Proximity Sensor", + .type = EV_SW, + .code = SW_FRONT_PROXIMITY, + .active_low = 0, + .can_disable = 1, + }, + { + .desc = "HED54XXU11 Hall Effect Sensor", + .type = EV_SW, + .code = SW_LID, /* FIXME arbitrary usage */ + .active_low = 0, + .can_disable = 1, + } +}; + +static struct regulator *gpio_keys_regulator; +static int mop500_gpio_keys_activate(struct device *dev); +static void mop500_gpio_keys_deactivate(struct device *dev); + +static struct gpio_keys_platform_data mop500_gpio_keys_data = { + .buttons = mop500_gpio_keys, + .nbuttons = ARRAY_SIZE(mop500_gpio_keys), + .enable = mop500_gpio_keys_activate, + .disable = mop500_gpio_keys_deactivate, +}; + +static struct platform_device mop500_gpio_keys_device = { + .name = "gpio-keys", + .id = 0, + .dev = { + .platform_data = &mop500_gpio_keys_data, + }, +}; + +static int mop500_gpio_keys_activate(struct device *dev) +{ + gpio_keys_regulator = regulator_get(&mop500_gpio_keys_device.dev, + "vcc"); + if (IS_ERR(gpio_keys_regulator)) { + dev_err(&mop500_gpio_keys_device.dev, "no regulator\n"); + return PTR_ERR(gpio_keys_regulator); + } + regulator_enable(gpio_keys_regulator); + + /* + * Please be aware that the start-up time of the SFH7741 is + * 120 ms and during that time the output is undefined. + */ + + return 0; +} + +static void mop500_gpio_keys_deactivate(struct device *dev) +{ + if (!IS_ERR(gpio_keys_regulator)) { + regulator_disable(gpio_keys_regulator); + regulator_put(gpio_keys_regulator); + } +} + +static __init void mop500_gpio_keys_init(void) +{ + struct ux500_pins *gpio_keys_pins = ux500_pins_get("gpio-keys.0"); + + if (gpio_keys_pins == NULL) { + pr_err("gpio_keys: Fail to get pins\n"); + return; + } + + ux500_pins_enable(gpio_keys_pins); + if (type_of_uib == U8500UIB_R3) + mop500_gpio_keys[0].gpio = PIN_NUM(gpio_keys_pins->cfg[2]); + else + mop500_gpio_keys[0].gpio = PIN_NUM(gpio_keys_pins->cfg[0]); + mop500_gpio_keys[1].gpio = PIN_NUM(gpio_keys_pins->cfg[1]); +} +#else +static inline void mop500_gpio_keys_init(void) { } +#endif + +/* add any platform devices here - TODO */ +static struct platform_device *mop500_uib_platform_devs[] __initdata = { +#ifdef CONFIG_UX500_GPIO_KEYS + &mop500_gpio_keys_device, +#endif +}; + /* * Detect the UIB attached based on the presence or absence of i2c devices. */ @@ -177,7 +273,9 @@ static int __init mop500_uib_init(void) uib = &mop500_uibs[STUIB]; } __mop500_uib_init(uib, "detected"); - + mop500_gpio_keys_init(); + platform_add_devices(mop500_uib_platform_devs, + ARRAY_SIZE(mop500_uib_platform_devs)); return 0; } diff --git a/arch/arm/mach-ux500/board-mop500.c b/arch/arm/mach-ux500/board-mop500.c index 8df987925da..1200db26f75 100644 --- a/arch/arm/mach-ux500/board-mop500.c +++ b/arch/arm/mach-ux500/board-mop500.c @@ -653,43 +653,6 @@ static void __init mop500_i2c_init(void) db8500_add_i2c3(&u8500_i2c3_data); } -#ifdef CONFIG_UX500_GPIO_KEYS -static struct gpio_keys_button mop500_gpio_keys[] = { - { - .desc = "SFH7741 Proximity Sensor", - .type = EV_SW, - .code = SW_FRONT_PROXIMITY, - .active_low = 0, - .can_disable = 1, - }, - { - .desc = "HED54XXU11 Hall Effect Sensor", - .type = EV_SW, - .code = SW_LID, /* FIXME arbitrary usage */ - .active_low = 0, - .can_disable = 1, - } -}; - -static struct regulator *gpio_keys_regulator; -static int mop500_gpio_keys_activate(struct device *dev); -static void mop500_gpio_keys_deactivate(struct device *dev); - -static struct gpio_keys_platform_data mop500_gpio_keys_data = { - .buttons = mop500_gpio_keys, - .nbuttons = ARRAY_SIZE(mop500_gpio_keys), - .enable = mop500_gpio_keys_activate, - .disable = mop500_gpio_keys_deactivate, -}; - -static struct platform_device mop500_gpio_keys_device = { - .name = "gpio-keys", - .id = 0, - .dev = { - .platform_data = &mop500_gpio_keys_data, - }, -}; - #ifdef CONFIG_REGULATOR_FIXED_VOLTAGE static struct platform_device snowball_gpio_wlan_vbat_regulator_device = { .name = "reg-fixed-voltage", @@ -708,51 +671,6 @@ static struct platform_device snowball_gpio_en_3v3_regulator_device = { }; #endif -static int mop500_gpio_keys_activate(struct device *dev) -{ - gpio_keys_regulator = regulator_get(&mop500_gpio_keys_device.dev, - "vcc"); - if (IS_ERR(gpio_keys_regulator)) { - dev_err(&mop500_gpio_keys_device.dev, "no regulator\n"); - return PTR_ERR(gpio_keys_regulator); - } - regulator_enable(gpio_keys_regulator); - - /* - * Please be aware that the start-up time of the SFH7741 is - * 120 ms and during that time the output is undefined. - */ - - return 0; -} - -static void mop500_gpio_keys_deactivate(struct device *dev) -{ - if (!IS_ERR(gpio_keys_regulator)) { - regulator_disable(gpio_keys_regulator); - regulator_put(gpio_keys_regulator); - } -} - -static __init void mop500_gpio_keys_init(void) -{ - struct ux500_pins *gpio_keys_pins = ux500_pins_get("gpio-keys.0"); - - if (gpio_keys_pins == NULL) { - pr_err("gpio_keys: Fail to get pins\n"); - return; - } - - ux500_pins_enable(gpio_keys_pins); - - mop500_gpio_keys[0].gpio = PIN_NUM(gpio_keys_pins->cfg[0]); - mop500_gpio_keys[1].gpio = PIN_NUM(gpio_keys_pins->cfg[1]); - -} -#else -static inline void mop500_gpio_keys_init(void) { } -#endif - #ifdef CONFIG_LEDS_PWM static struct led_pwm pwm_leds_data[] = { [0] = { @@ -957,9 +875,6 @@ static struct platform_device *mop500_platform_devs[] __initdata = { #ifdef CONFIG_STE_TRACE_MODEM &u8500_trace_modem, #endif -#ifdef CONFIG_UX500_GPIO_KEYS - &mop500_gpio_keys_device, -#endif #ifdef CONFIG_LEDS_PWM &ux500_leds_device, #endif @@ -1222,7 +1137,6 @@ static void __init mop500_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif - mop500_gpio_keys_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); @@ -1309,7 +1223,6 @@ static void __init hrefv60_init_machine(void) ARRAY_SIZE(u8500_hsi_devices)); #endif - mop500_gpio_keys_init(); platform_add_devices(mop500_platform_devs, ARRAY_SIZE(mop500_platform_devs)); -- cgit v1.2.3 From e441c4b9d55538320e8486d7b023809390b79550 Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:47:04 +0100 Subject: Android:lps001wp: add early suspend,late resume add early suspend,late resume functionlity for pressure sensor. ST-Ericsson ID: 371766 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:If517adc3bbef3d203a9be2af946c3264cb35b265 Signed-off-by: Naga Radhesh --- drivers/input/misc/lps001wp_prs.c | 58 +++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/drivers/input/misc/lps001wp_prs.c b/drivers/input/misc/lps001wp_prs.c index cb60762ac61..9662b6ce489 100644 --- a/drivers/input/misc/lps001wp_prs.c +++ b/drivers/input/misc/lps001wp_prs.c @@ -49,12 +49,12 @@ #include #include - - +#ifdef CONFIG_HAS_EARLYSUSPEND +#include +#endif #define DEBUG 1 - #define PR_ABS_MAX 0xffff #define PR_ABS_MIN 0x0000 #define PR_DLT_MAX 0x7ffff @@ -153,6 +153,9 @@ struct lps001wp_prs_data { struct delayed_work input_work; struct input_dev *input_dev; +#ifdef CONFIG_HAS_EARLYSUSPEND + struct early_suspend early_suspend; +#endif int hw_initialized; /* hw_working=-1 means not tested yet */ @@ -178,6 +181,11 @@ struct outputdata { s16 deltapress; }; +#ifdef CONFIG_HAS_EARLYSUSPEND +static void lps001wp_prs_early_suspend(struct early_suspend *data); +static void lps001wp_prs_late_resume(struct early_suspend *data); +#endif + static int lps001wp_prs_i2c_read(struct lps001wp_prs_data *prs, u8 *buf, int len) @@ -1177,6 +1185,13 @@ static int lps001wp_prs_probe(struct i2c_client *client, "device LPS001WP_PRS_DEV_NAME sysfs register failed\n"); goto err_input_cleanup; } +#ifdef CONFIG_HAS_EARLYSUSPEND + prs->early_suspend.level = + EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1; + prs->early_suspend.suspend = lps001wp_prs_early_suspend; + prs->early_suspend.resume = lps001wp_prs_late_resume; + register_early_suspend(&prs->early_suspend); +#endif lps001wp_prs_device_power_off(prs); @@ -1233,24 +1248,44 @@ static int __devexit lps001wp_prs_remove(struct i2c_client *client) return 0; } - -static int lps001wp_prs_resume(struct i2c_client *client) +#if (!defined(CONFIG_HAS_EARLYSUSPEND) && defined(CONFIG_PM)) +static int lps001wp_prs_resume(struct device *dev) { - struct lps001wp_prs_data *prs = i2c_get_clientdata(client); + struct lps001wp_prs_data *prs = dev_get_drvdata(dev); if (prs->on_before_suspend) return lps001wp_prs_enable(prs); return 0; } -static int lps001wp_prs_suspend(struct i2c_client *client, pm_message_t mesg) +static int lps001wp_prs_suspend(struct device *dev) { - struct lps001wp_prs_data *prs = i2c_get_clientdata(client); - + struct lps001wp_prs_data *prs = dev_get_drvdata(dev); prs->on_before_suspend = atomic_read(&prs->enabled); return lps001wp_prs_disable(prs); } +static const struct dev_pm_ops lps001wp_prs_dev_pm_ops = { + .suspend = lps001wp_prs_suspend, + .resume = lps001wp_prs_resume, +}; +#else +static void lps001wp_prs_early_suspend(struct early_suspend *data) +{ + struct lps001wp_prs_data *prs = + container_of(data, struct lps001wp_prs_data, early_suspend); + prs->on_before_suspend = atomic_read(&prs->enabled); + lps001wp_prs_disable(prs); +} + +static void lps001wp_prs_late_resume(struct early_suspend *data) +{ + struct lps001wp_prs_data *prs = + container_of(data, struct lps001wp_prs_data, early_suspend); + if (prs->on_before_suspend) + lps001wp_prs_enable(prs); +} +#endif static const struct i2c_device_id lps001wp_prs_id[] = { { LPS001WP_PRS_DEV_NAME, 0}, { },}; @@ -1260,12 +1295,13 @@ static struct i2c_driver lps001wp_prs_driver = { .driver = { .name = LPS001WP_PRS_DEV_NAME, .owner = THIS_MODULE, +#if (!defined(CONFIG_HAS_EARLYSUSPEND) && defined(CONFIG_PM)) + .pm = &lps001wp_prs_dev_pm_ops, +#endif }, .probe = lps001wp_prs_probe, .remove = __devexit_p(lps001wp_prs_remove), .id_table = lps001wp_prs_id, - .resume = lps001wp_prs_resume, - .suspend = lps001wp_prs_suspend, }; static int __init lps001wp_prs_init(void) -- cgit v1.2.3 From 32b749006e4e8fb283c5cf3bdc3ec24cf2a45a6e Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:47:05 +0100 Subject: lps001wp_prs:add compilation switch for work queue add compilation switch for work queue,input subsystem. ST-Ericsson ID: 371766 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:I0cb3ea3e4f9ea64de427a2b0784032a4eab55580 Signed-off-by: Naga Radhesh --- drivers/input/misc/Kconfig | 9 +++++ drivers/input/misc/lps001wp_prs.c | 82 ++++++++++----------------------------- 2 files changed, 29 insertions(+), 62 deletions(-) diff --git a/drivers/input/misc/Kconfig b/drivers/input/misc/Kconfig index 149c23a5805..80e3fe2b914 100644 --- a/drivers/input/misc/Kconfig +++ b/drivers/input/misc/Kconfig @@ -296,6 +296,15 @@ config INPUT_LPS001WP This is a pressure sensor connected to I2C, mounted on the snowball and other ST-E boards +config LPS001WP_INPUT_DEVICE + bool "ST LPS001WP INPUT DEVICE" + depends on INPUT_LPS001WP + default n + help + This driver allows device to be used as an input device + need to be enabled only when input device support + is required. + config INPUT_POWERMATE tristate "Griffin PowerMate and Contour Jog support" depends on USB_ARCH_HAS_HCD diff --git a/drivers/input/misc/lps001wp_prs.c b/drivers/input/misc/lps001wp_prs.c index 9662b6ce489..9a362bffc53 100644 --- a/drivers/input/misc/lps001wp_prs.c +++ b/drivers/input/misc/lps001wp_prs.c @@ -97,9 +97,8 @@ /* Barometer and Termometer output data rate ODR */ #define LPS001WP_PRS_ODR_MASK 0x30 /* Mask to access odr bits only */ #define LPS001WP_PRS_ODR_7_1 0x00 /* 7Hz baro and 1Hz term ODR */ -#define LPS001WP_PRS_ODR_7_7 0x01 /* 7Hz baro and 7Hz term ODR */ -#define LPS001WP_PRS_ODR_12_12 0x11 /* 12.5Hz baro and 12.5Hz term ODR */ - +#define LPS001WP_PRS_ODR_7_7 0x10 /* 7Hz baro and 7Hz term ODR */ +#define LPS001WP_PRS_ODR_12_12 0x30 /* 12.5Hz baro and 12.5Hz term ODR */ #define LPS001WP_PRS_ENABLE_MASK 0x40 /* */ #define LPS001WP_PRS_DIFF_MASK 0x08 @@ -150,9 +149,10 @@ struct lps001wp_prs_data { struct lps001wp_prs_platform_data *pdata; struct mutex lock; +#ifdef CONFIG_LPS001WP_INPUT_DEVICE struct delayed_work input_work; - struct input_dev *input_dev; +#endif #ifdef CONFIG_HAS_EARLYSUSPEND struct early_suspend early_suspend; #endif @@ -254,26 +254,6 @@ static int lps001wp_prs_i2c_write(struct lps001wp_prs_data *prs, return err; } -static int lps001wp_prs_i2c_update(struct lps001wp_prs_data *prs, - u8 reg_address, u8 mask, u8 new_bit_values) -{ - int err = -1; - u8 rdbuf[1] = { reg_address }; - u8 wrbuf[2] = { reg_address , 0x00 }; - - u8 init_val; - u8 updated_val; - err = lps001wp_prs_i2c_read(prs, rdbuf, 1); - if (!(err < 0)) { - init_val = rdbuf[0]; - updated_val = ((mask & new_bit_values) | ((~mask) & init_val)); - wrbuf[1] = updated_val; - err = lps001wp_prs_i2c_write(prs, wrbuf, 2); - } - return err; -} -/* */ - static int lps001wp_prs_register_write(struct lps001wp_prs_data *prs, u8 *buf, u8 reg_address, u8 new_value) { @@ -626,6 +606,7 @@ static int lps001wp_prs_get_presstemp_data(struct lps001wp_prs_data *prs, return err; } +#ifdef CONFIG_LPS001WP_INPUT_DEVICE static void lps001wp_prs_report_values(struct lps001wp_prs_data *prs, struct outputdata *out) { @@ -634,6 +615,7 @@ static void lps001wp_prs_report_values(struct lps001wp_prs_data *prs, input_report_abs(prs->input_dev, ABS_DLTPR, out->deltapress); input_sync(prs->input_dev); } +#endif static int lps001wp_prs_enable(struct lps001wp_prs_data *prs) { @@ -645,8 +627,10 @@ static int lps001wp_prs_enable(struct lps001wp_prs_data *prs) atomic_set(&prs->enabled, 0); return err; } +#ifdef CONFIG_LPS001WP_INPUT_DEVICE schedule_delayed_work(&prs->input_work, msecs_to_jiffies(prs->pdata->poll_interval)); +#endif } return 0; @@ -655,44 +639,15 @@ static int lps001wp_prs_enable(struct lps001wp_prs_data *prs) static int lps001wp_prs_disable(struct lps001wp_prs_data *prs) { if (atomic_cmpxchg(&prs->enabled, 1, 0)) { +#ifdef CONFIG_LPS001WP_INPUT_DEVICE cancel_delayed_work_sync(&prs->input_work); +#endif lps001wp_prs_device_power_off(prs); } return 0; } -static ssize_t read_single_reg(struct device *dev, char *buf, u8 reg) -{ - ssize_t ret; - struct lps001wp_prs_data *prs = dev_get_drvdata(dev); - int rc = 0; - - u8 data = reg; - rc = lps001wp_prs_i2c_read(prs, &data, 1); - /*TODO: error need to be managed */ - ret = sprintf(buf, "0x%02x\n", data); - return ret; - -} - -static int write_reg(struct device *dev, const char *buf, u8 reg) -{ - int rc = 0; - struct lps001wp_prs_data *prs = dev_get_drvdata(dev); - u8 x[2]; - unsigned long val; - - if (strict_strtoul(buf, 16, &val)) - return -EINVAL; - - x[0] = reg; - x[1] = val; - rc = lps001wp_prs_i2c_write(prs, x, 1); - /*TODO: error need to be managed */ - return rc; -} - static ssize_t attr_get_polling_rate(struct device *dev, struct device_attribute *attr, char *buf) @@ -935,7 +890,7 @@ static int remove_sysfs_interfaces(struct device *dev) return 0; } - +#ifdef CONFIG_LPS001WP_INPUT_DEVICE static void lps001wp_prs_input_work_func(struct work_struct *work) { struct lps001wp_prs_data *prs; @@ -972,7 +927,7 @@ void lps001wp_prs_input_close(struct input_dev *dev) lps001wp_prs_disable(prs); } - +#endif static int lps001wp_prs_validate_pdata(struct lps001wp_prs_data *prs) { @@ -987,11 +942,10 @@ static int lps001wp_prs_validate_pdata(struct lps001wp_prs_data *prs) return 0; } - +#ifdef CONFIG_LPS001WP_INPUT_DEVICE static int lps001wp_prs_input_init(struct lps001wp_prs_data *prs) { int err; - INIT_DELAYED_WORK(&prs->input_work, lps001wp_prs_input_work_func); prs->input_dev = input_allocate_device(); if (!prs->input_dev) { @@ -1041,7 +995,7 @@ static void lps001wp_prs_input_cleanup(struct lps001wp_prs_data *prs) input_unregister_device(prs->input_dev); input_free_device(prs->input_dev); } - +#endif static int lps001wp_prs_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1171,13 +1125,13 @@ static int lps001wp_prs_probe(struct i2c_client *client, dev_err(&client->dev, "update_odr failed\n"); goto err_power_off; } - +#ifdef CONFIG_LPS001WP_INPUT_DEVICE err = lps001wp_prs_input_init(prs); if (err < 0) { dev_err(&client->dev, "input init failed\n"); goto err_power_off; } - +#endif err = create_sysfs_interfaces(&client->dev); if (err < 0) { @@ -1211,7 +1165,9 @@ remove_sysfs_int: remove_sysfs_interfaces(&client->dev); */ err_input_cleanup: +#ifdef CONFIG_LPS001WP_INPUT_DEVICE lps001wp_prs_input_cleanup(prs); +#endif err_power_off: lps001wp_prs_device_power_off(prs); err2: @@ -1233,7 +1189,9 @@ static int __devexit lps001wp_prs_remove(struct i2c_client *client) { struct lps001wp_prs_data *prs = i2c_get_clientdata(client); +#ifdef CONFIG_LPS001WP_INPUT_DEVICE lps001wp_prs_input_cleanup(prs); +#endif lps001wp_prs_device_power_off(prs); remove_sysfs_interfaces(&client->dev); -- cgit v1.2.3 From d77fe9cc34be73c9e19a37ce17b24cfd4ba0c754 Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:47:06 +0100 Subject: ANDROID:input:lps001wp_prs:add regulator,sysfs add regulator,sysfs paths and add error handling in all error cases. ST-Ericsson ID: 371766 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:I9efe9ab97b1a7d051d26e7a803aa7cecccc4d6f4 Signed-off-by: Naga Radhesh Conflicts: drivers/input/misc/lps001wp_prs.c --- drivers/input/misc/lps001wp_prs.c | 249 +++++++++++++++++++++++++++++++------- 1 file changed, 207 insertions(+), 42 deletions(-) diff --git a/drivers/input/misc/lps001wp_prs.c b/drivers/input/misc/lps001wp_prs.c index 9a362bffc53..338d0ed5380 100644 --- a/drivers/input/misc/lps001wp_prs.c +++ b/drivers/input/misc/lps001wp_prs.c @@ -68,7 +68,7 @@ #define OUTDATA_REG 0x28 -#define INDATA_REG 0X30 +#define REF_PRESS_REG 0X30 #define WHOAMI_LPS001WP_PRS 0xBA /* Expctd content for WAI */ @@ -83,7 +83,7 @@ #define PRESS_OUT_L OUTDATA_REG -#define REF_P_L INDATA_REG /* pressure reference */ +#define REF_P_L REF_PRESS_REG /* pressure reference */ #define REF_P_H 0x31 /* pressure reference */ #define THS_P_L 0x32 /* pressure threshold */ #define THS_P_H 0x33 /* pressure threshold */ @@ -144,6 +144,24 @@ static const struct { {1000, LPS001WP_PRS_ODR_7_1 }, }; +/** + * struct lps001wp_prs_data - data structure used by lps001wp_prs driver + * @client: i2c client + * @pdata: lsm303dlh platform data + * @lock: mutex lock for sysfs operations + * @input_work: work queue to read sensor data + * @input_dev: input device + * @regulator: regulator + * @early_suspend: early suspend structure + * @hw_initialized: saves hw initialisation status + * @hw_working: saves hw status + * @diff_enabled: store value of diff enable + * @lpowmode_enabled: flag to set lowpower mode + * @enabled: to store mode of device + * @on_before_suspend: to store status of device during suspend + * @resume_state:store regester values + * @reg_addr: stores reg address to debug + */ struct lps001wp_prs_data { struct i2c_client *client; struct lps001wp_prs_platform_data *pdata; @@ -257,7 +275,7 @@ static int lps001wp_prs_i2c_write(struct lps001wp_prs_data *prs, static int lps001wp_prs_register_write(struct lps001wp_prs_data *prs, u8 *buf, u8 reg_address, u8 new_value) { - int err = -1; + int err = -EINVAL; /* Sets configuration register at reg_address * NOTE: this is a straight overwrite */ @@ -273,7 +291,7 @@ static int lps001wp_prs_register_read(struct lps001wp_prs_data *prs, u8 *buf, u8 reg_address) { - int err = -1; + int err = -EINVAL; buf[0] = (reg_address); err = lps001wp_prs_i2c_read(prs, buf, 1); @@ -283,7 +301,7 @@ static int lps001wp_prs_register_read(struct lps001wp_prs_data *prs, u8 *buf, static int lps001wp_prs_register_update(struct lps001wp_prs_data *prs, u8 *buf, u8 reg_address, u8 mask, u8 new_bit_values) { - int err = -1; + int err = -EINVAL; u8 init_val; u8 updated_val; err = lps001wp_prs_register_read(prs, buf, reg_address); @@ -301,10 +319,11 @@ static int lps001wp_prs_register_update(struct lps001wp_prs_data *prs, u8 *buf, static int lps001wp_prs_hw_init(struct lps001wp_prs_data *prs) { - int err = -1; + int err = -EINVAL; u8 buf[6]; - printk(KERN_DEBUG "%s: hw init start\n", LPS001WP_PRS_DEV_NAME); + dev_dbg(&prs->client->dev, "%s: hw init start\n", + LPS001WP_PRS_DEV_NAME); buf[0] = WHO_AM_I; err = lps001wp_prs_i2c_read(prs, buf, 1); @@ -313,12 +332,12 @@ static int lps001wp_prs_hw_init(struct lps001wp_prs_data *prs) else prs->hw_working = 1; if (buf[0] != WHOAMI_LPS001WP_PRS) { - err = -1; /* TODO:choose the right coded error */ + err = -EINVAL; /* TODO:choose the right coded error */ goto error_unknown_device; } - buf[0] = (I2C_AUTO_INCREMENT | INDATA_REG); + buf[0] = (I2C_AUTO_INCREMENT | REF_PRESS_REG); buf[1] = prs->resume_state[RES_REF_P_L]; buf[2] = prs->resume_state[RES_REF_P_H]; buf[3] = prs->resume_state[RES_THS_P_L]; @@ -343,7 +362,7 @@ static int lps001wp_prs_hw_init(struct lps001wp_prs_data *prs) prs->hw_initialized = 1; - printk(KERN_DEBUG "%s: hw init done\n", LPS001WP_PRS_DEV_NAME); + dev_dbg(&prs->client->dev, "%s: hw init done\n", LPS001WP_PRS_DEV_NAME); return 0; error_firstread: @@ -386,7 +405,7 @@ static void lps001wp_prs_device_power_off(struct lps001wp_prs_data *prs) static int lps001wp_prs_device_power_on(struct lps001wp_prs_data *prs) { - int err = -1; + int err = -EINVAL; /* get the regulator the first time */ if (!prs->regulator) { @@ -420,7 +439,7 @@ static int lps001wp_prs_device_power_on(struct lps001wp_prs_data *prs) int lps001wp_prs_update_odr(struct lps001wp_prs_data *prs, int poll_interval_ms) { - int err = -1; + int err = -EINVAL; int i; u8 buf[2]; @@ -471,12 +490,17 @@ error: static int lps001wp_prs_set_press_reference(struct lps001wp_prs_data *prs, u16 new_reference) { - int err = -1; + int err = -EINVAL; u8 const reg_addressL = REF_P_L; u8 const reg_addressH = REF_P_H; u8 bit_valuesL, bit_valuesH; u8 buf[2]; - + /* + * We need to set new configurations, only if device + * is currently enabled + */ + if (!atomic_read(&prs->enabled)) + return err; bit_valuesL = (u8) (new_reference & 0x00FF); bit_valuesH = (u8)((new_reference & 0xFF00) >> 8); @@ -499,12 +523,17 @@ static int lps001wp_prs_set_press_reference(struct lps001wp_prs_data *prs, static int lps001wp_prs_get_press_reference(struct lps001wp_prs_data *prs, u16 *buf16) { - int err = -1; + int err = -EINVAL; u8 bit_valuesL, bit_valuesH; u8 buf[2] = {0}; u16 temp = 0; - + /* + * We need to read configurations, only if device + * is currently enabled + */ + if (!atomic_read(&prs->enabled)) + return err; err = lps001wp_prs_register_read(prs, buf, REF_P_L); if (err < 0) return err; @@ -522,11 +551,17 @@ static int lps001wp_prs_get_press_reference(struct lps001wp_prs_data *prs, static int lps001wp_prs_lpow_manage(struct lps001wp_prs_data *prs, u8 control) { - int err = -1; + int err = -EINVAL; u8 buf[2] = {0x00, 0x00}; u8 const mask = LPS001WP_PRS_LPOW_MASK; u8 bit_values = LPS001WP_PRS_LPOW_OFF; + /* + * We need to set new configurations, only if device + * is currently enabled + */ + if (!atomic_read(&prs->enabled)) + return err; if (control >= LPS001WP_PRS_LPOWER_EN) { bit_values = LPS001WP_PRS_LPOW_ON; } @@ -547,11 +582,17 @@ static int lps001wp_prs_lpow_manage(struct lps001wp_prs_data *prs, u8 control) static int lps001wp_prs_diffen_manage(struct lps001wp_prs_data *prs, u8 control) { - int err = -1; + int err = -EINVAL; u8 buf[2] = {0x00, 0x00}; u8 const mask = LPS001WP_PRS_DIFF_MASK; u8 bit_values = LPS001WP_PRS_DIFF_OFF; + /* + * We need to set new configurations, only if device + * is currently enabled + */ + if (!atomic_read(&prs->enabled)) + return err; if (control >= LPS001WP_PRS_DIFF_ENABLE) { bit_values = LPS001WP_PRS_DIFF_ON; } @@ -574,7 +615,7 @@ static int lps001wp_prs_diffen_manage(struct lps001wp_prs_data *prs, u8 control) static int lps001wp_prs_get_presstemp_data(struct lps001wp_prs_data *prs, struct outputdata *out) { - int err = -1; + int err = -EINVAL; /* Data bytes from hardware PRESS_OUT_L, PRESS_OUT_H, * TEMP_OUT_L, TEMP_OUT_H, * DELTA_L, DELTA_H */ @@ -597,8 +638,8 @@ static int lps001wp_prs_get_presstemp_data(struct lps001wp_prs_data *prs, abspr = ((((u16) prs_data[1] << 8) | ((u16) prs_data[0]))); temperature = ((s16) (((u16) prs_data[3] << 8) | ((u16)prs_data[2]))); - out->abspress = abspr; - out->temperature = temperature; + out->abspress = (abspr >> SENSITIVITY_P_SHIFT); + out->temperature = (temperature >> SENSITIVITY_T_SHIFT); deltapr = ((s16) (((u16) prs_data[5] << 8) | ((u16)prs_data[4]))); out->deltapress = deltapr; @@ -622,6 +663,8 @@ static int lps001wp_prs_enable(struct lps001wp_prs_data *prs) int err; if (!atomic_cmpxchg(&prs->enabled, 0, 1)) { + if (prs->regulator) + regulator_enable(prs->regulator); err = lps001wp_prs_device_power_on(prs); if (err < 0) { atomic_set(&prs->enabled, 0); @@ -643,6 +686,8 @@ static int lps001wp_prs_disable(struct lps001wp_prs_data *prs) cancel_delayed_work_sync(&prs->input_work); #endif lps001wp_prs_device_power_off(prs); + if (prs->regulator) + regulator_disable(prs->regulator); } return 0; @@ -666,6 +711,7 @@ static ssize_t attr_set_polling_rate(struct device *dev, { struct lps001wp_prs_data *prs = dev_get_drvdata(dev); unsigned long interval_ms; + int err = -EINVAL; if (strict_strtoul(buf, 10, &interval_ms)) return -EINVAL; @@ -673,7 +719,12 @@ static ssize_t attr_set_polling_rate(struct device *dev, return -EINVAL; mutex_lock(&prs->lock); prs->pdata->poll_interval = interval_ms; - lps001wp_prs_update_odr(prs, interval_ms); + err = lps001wp_prs_update_odr(prs, interval_ms); + if (err < 0) { + dev_err(&prs->client->dev, "failed to update odr %ld\n", + interval_ms); + size = err; + } mutex_unlock(&prs->lock); return size; } @@ -696,12 +747,18 @@ static ssize_t attr_set_diff_enable(struct device *dev, { struct lps001wp_prs_data *prs = dev_get_drvdata(dev); unsigned long val; + int err = -EINVAL; if (strict_strtoul(buf, 10, &val)) return -EINVAL; mutex_lock(&prs->lock); - lps001wp_prs_diffen_manage(prs, (u8) val); + err = lps001wp_prs_diffen_manage(prs, (u8) val); + if (err < 0) { + dev_err(&prs->client->dev, "failed to diff enable %ld\n", val); + mutex_unlock(&prs->lock); + return err; + } mutex_unlock(&prs->lock); return size; } @@ -735,15 +792,17 @@ static ssize_t attr_set_enable(struct device *dev, static ssize_t attr_get_press_ref(struct device *dev, struct device_attribute *attr, char *buf) { - int err = -1; + int err = -EINVAL; struct lps001wp_prs_data *prs = dev_get_drvdata(dev); u16 val = 0; mutex_lock(&prs->lock); err = lps001wp_prs_get_press_reference(prs, &val); mutex_unlock(&prs->lock); - if (err < 0) + if (err < 0) { + dev_err(&prs->client->dev, "failed to get ref press\n"); return err; + } return sprintf(buf, "%d\n", val); } @@ -752,7 +811,7 @@ static ssize_t attr_set_press_ref(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { - int err = -1; + int err = -EINVAL; struct lps001wp_prs_data *prs = dev_get_drvdata(dev); unsigned long val = 0; @@ -765,8 +824,11 @@ static ssize_t attr_set_press_ref(struct device *dev, mutex_lock(&prs->lock); err = lps001wp_prs_set_press_reference(prs, val); mutex_unlock(&prs->lock); - if (err < 0) + if (err < 0) { + dev_err(&prs->client->dev, "failed to set ref press %ld\n", + val); return err; + } return size; } @@ -786,7 +848,7 @@ static ssize_t attr_set_lowpowmode(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) { - int err = -1; + int err = -EINVAL; struct lps001wp_prs_data *prs = dev_get_drvdata(dev); unsigned long val; @@ -796,12 +858,86 @@ static ssize_t attr_set_lowpowmode(struct device *dev, mutex_lock(&prs->lock); err = lps001wp_prs_lpow_manage(prs, (u8) val); mutex_unlock(&prs->lock); - if (err < 0) + if (err < 0) { + dev_err(&prs->client->dev, "failed to set low powermode\n"); return err; + } return size; } +static ssize_t lps001wp_prs_get_press_data(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct lps001wp_prs_data *prs = dev_get_drvdata(dev); + struct outputdata out; + int err = -EINVAL; + mutex_lock(&prs->lock); + /* + * If device is currently enabled, we need to read + * data from it. + */ + if (!atomic_read(&prs->enabled)) + goto out; + err = lps001wp_prs_get_presstemp_data(prs, &out); + if (err < 0) { + dev_err(&prs->client->dev, "get_pressure_data failed\n"); + goto out; + } + mutex_unlock(&prs->lock); + return sprintf(buf, "%d", out.abspress); +out: + mutex_unlock(&prs->lock); + return err; +} +static ssize_t lps001wp_prs_get_deltapr_data(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct lps001wp_prs_data *prs = dev_get_drvdata(dev); + struct outputdata out; + int err = -EINVAL; + mutex_lock(&prs->lock); + /* + * If device is currently enabled, we need to read + * data from it. + */ + if (!atomic_read(&prs->enabled)) { + mutex_unlock(&prs->lock); + return err; + } + err = lps001wp_prs_get_presstemp_data(prs, &out); + if (err < 0) { + dev_err(&prs->client->dev, "get_deltapress_data failed\n"); + mutex_unlock(&prs->lock); + return err; + } + mutex_unlock(&prs->lock); + return sprintf(buf, "%d", out.deltapress); +} +static ssize_t lps001wp_prs_get_temp_data(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct lps001wp_prs_data *prs = dev_get_drvdata(dev); + struct outputdata out; + int err = -EINVAL; + mutex_lock(&prs->lock); + /* + * If device is currently enabled, we need to read + * data from it. + */ + if (!atomic_read(&prs->enabled)) { + mutex_unlock(&prs->lock); + return err; + } + err = lps001wp_prs_get_presstemp_data(prs, &out); + if (err < 0) { + dev_err(&prs->client->dev, "get_temperature_data failed\n"); + mutex_unlock(&prs->lock); + return err; + } + mutex_unlock(&prs->lock); + return sprintf(buf, "%d", out.temperature); +} #ifdef DEBUG static ssize_t attr_reg_set(struct device *dev, struct device_attribute *attr, const char *buf, size_t size) @@ -856,14 +992,21 @@ static ssize_t attr_addr_set(struct device *dev, struct device_attribute *attr, static struct device_attribute attributes[] = { - __ATTR(pollrate_ms, 0664, attr_get_polling_rate, attr_set_polling_rate), - __ATTR(enable, 0664, attr_get_enable, attr_set_enable), - __ATTR(diff_enable, 0664, attr_get_diff_enable, attr_set_diff_enable), - __ATTR(press_reference, 0664, attr_get_press_ref, attr_set_press_ref), - __ATTR(lowpow_enable, 0664, attr_get_lowpowmode, attr_set_lowpowmode), + __ATTR(pollrate_ms, S_IWUSR | S_IRUGO, attr_get_polling_rate, + attr_set_polling_rate), + __ATTR(enable, S_IWUSR | S_IRUGO, attr_get_enable, attr_set_enable), + __ATTR(diff_enable, S_IWUSR | S_IRUGO, attr_get_diff_enable, + attr_set_diff_enable), + __ATTR(press_reference, S_IWUSR | S_IRUGO, attr_get_press_ref, + attr_set_press_ref), + __ATTR(lowpow_enable, S_IWUSR | S_IRUGO, attr_get_lowpowmode, + attr_set_lowpowmode), + __ATTR(press_data, S_IRUGO, lps001wp_prs_get_press_data, NULL), + __ATTR(temp_data, S_IRUGO, lps001wp_prs_get_temp_data, NULL), + __ATTR(deltapr_data, S_IRUGO, lps001wp_prs_get_deltapr_data, NULL), #ifdef DEBUG - __ATTR(reg_value, 0664, attr_reg_get, attr_reg_set), - __ATTR(reg_addr, 0220, NULL, attr_addr_set), + __ATTR(reg_value, S_IWUSR | S_IRUGO, attr_reg_get, attr_reg_set), + __ATTR(reg_addr, S_IWUSR, NULL, attr_addr_set), #endif }; @@ -1000,7 +1143,7 @@ static int lps001wp_prs_probe(struct i2c_client *client, const struct i2c_device_id *id) { struct lps001wp_prs_data *prs; - int err = -1; + int err = -EINVAL; int tempvalue; pr_info("%s: probe start.\n", LPS001WP_PRS_DEV_NAME); @@ -1050,23 +1193,31 @@ static int lps001wp_prs_probe(struct i2c_client *client, prs->client = client; i2c_set_clientdata(client, prs); + prs->regulator = regulator_get(&client->dev, "vdd"); + if (IS_ERR(prs->regulator)) { + dev_err(&client->dev, "failed to get regulator\n"); + err = PTR_ERR(prs->regulator); + prs->regulator = NULL; + } + if (prs->regulator) + regulator_enable(prs->regulator); if (i2c_smbus_read_byte(client) < 0) { - printk(KERN_ERR "i2c_smbus_read_byte error!!\n"); + dev_err(&client->dev, "i2c_smbus_read_byte error!!\n"); goto err_mutexunlockfreedata; } else { - printk(KERN_DEBUG "%s Device detected!\n", + dev_dbg(&client->dev, "%s Device detected!\n", LPS001WP_PRS_DEV_NAME); } /* read chip id */ tempvalue = i2c_smbus_read_word_data(client, WHO_AM_I); if ((tempvalue & 0x00FF) == WHOAMI_LPS001WP_PRS) { - printk(KERN_DEBUG "%s I2C driver registered!\n", + dev_dbg(&client->dev, "%s I2C driver registered!\n", LPS001WP_PRS_DEV_NAME); } else { prs->client = NULL; - printk(KERN_DEBUG "I2C driver not registered!" + dev_dbg(&client->dev, "I2C driver not registered!" " Device unknown\n"); goto err_mutexunlockfreedata; } @@ -1150,6 +1301,9 @@ static int lps001wp_prs_probe(struct i2c_client *client, lps001wp_prs_device_power_off(prs); + if (prs->regulator) + regulator_disable(prs->regulator); + /* As default, do not report information */ atomic_set(&prs->enabled, 0); @@ -1179,9 +1333,14 @@ exit_kfree_pdata: err_mutexunlockfreedata: mutex_unlock(&prs->lock); kfree(prs); + if (prs->regulator) { + regulator_disable(prs->regulator); + regulator_put(prs->regulator); + } exit_alloc_data_failed: exit_check_functionality_failed: - printk(KERN_ERR "%s: Driver Init failed\n", LPS001WP_PRS_DEV_NAME); + dev_err(&client->dev, "%s: Driver Init failed\n", + LPS001WP_PRS_DEV_NAME); return err; } @@ -1194,6 +1353,12 @@ static int __devexit lps001wp_prs_remove(struct i2c_client *client) #endif lps001wp_prs_device_power_off(prs); remove_sysfs_interfaces(&client->dev); + if (prs->regulator) { + /* Disable the regulator if device is enabled. */ + if (atomic_read(&prs->enabled)) + regulator_disable(prs->regulator); + regulator_put(prs->regulator); + } if (prs->pdata->exit) prs->pdata->exit(); -- cgit v1.2.3 From d525aabb9f015990cce09ae7e977fc62243b3b50 Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:47:07 +0100 Subject: lps001wp_prs:free prs struct after regulator free free the prs structure after freeing regulator ST-Ericsson ID: 401383 ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Change-Id:Iba5a833e427a83ad3e7201499f13e120545a307d Signed-off-by: Naga Radhesh --- drivers/input/misc/lps001wp_prs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/input/misc/lps001wp_prs.c b/drivers/input/misc/lps001wp_prs.c index 338d0ed5380..1618dfaa16f 100644 --- a/drivers/input/misc/lps001wp_prs.c +++ b/drivers/input/misc/lps001wp_prs.c @@ -1332,11 +1332,11 @@ exit_kfree_pdata: err_mutexunlockfreedata: mutex_unlock(&prs->lock); - kfree(prs); if (prs->regulator) { regulator_disable(prs->regulator); regulator_put(prs->regulator); } + kfree(prs); exit_alloc_data_failed: exit_check_functionality_failed: dev_err(&client->dev, "%s: Driver Init failed\n", -- cgit v1.2.3 From a87aadbd5d960fe6eec64a96b30dfd58ad17a1ef Mon Sep 17 00:00:00 2001 From: Naga RADHESH Y Date: Tue, 14 Feb 2012 07:47:08 +0100 Subject: mach-ux500: update Chipid by reading 0x0F register update ChipId by reading 0x0F register,this chipid is used in megnetometer driver to differentiate b/w lsm303dlh and lsm303dlhc device. ST-Ericsson ID: - ST-Ericsson Linux next: NA ST-Ericsson FOSS-OUT ID: Trivial Signed-off-by: Naga Radhesh --- arch/arm/mach-ux500/board-mop500-sensors.c | 33 +++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-ux500/board-mop500-sensors.c b/arch/arm/mach-ux500/board-mop500-sensors.c index bc08e332699..5ee7fec5357 100644 --- a/arch/arm/mach-ux500/board-mop500-sensors.c +++ b/arch/arm/mach-ux500/board-mop500-sensors.c @@ -80,7 +80,7 @@ static struct i2c_board_info __initdata mop500_2_i2c2_devices[] = { static struct i2c_board_info __initdata snowball_i2c2_devices[] = { { /* LSM303DLH Accelerometer */ - I2C_BOARD_INFO("lsm303dlh_a", 0x19), + I2C_BOARD_INFO("lsm303dlhc_a", 0x19), .platform_data = &lsm303dlh_pdata, }, }; @@ -121,6 +121,7 @@ void mop500_sensors_i2c_add(int busnum, struct i2c_board_info const *info, void mop500_sensors_probe_add_lsm303dlh_a(void) { static const int busnum = 2; + int status; struct i2c_adapter *adap; struct i2c_client *client; static const unsigned short i2c_addr_list[] = { @@ -130,6 +131,7 @@ void mop500_sensors_probe_add_lsm303dlh_a(void) I2C_BOARD_INFO("lsm303dlh_a", 0), .platform_data = &lsm303dlh_pdata, }; + union i2c_smbus_data data; adap = i2c_get_adapter(busnum); if (!adap) { @@ -143,6 +145,23 @@ void mop500_sensors_probe_add_lsm303dlh_a(void) pr_err(__FILE__ ": failed to register %s to i2c%d\n", i2c_info.type, busnum); + /* driver is different for LSM3030DLH(0x18) and LSM303DLHC(0x19)*/ + if (i2c_info.addr == 0x19) { + snprintf(i2c_info.type, sizeof(i2c_info.type), "lsm303dlhc_a"); + } + /* + * From the i2c_new_probed_device() function we will come to know + * the adress of the device, so read 0x0F register to get chipID. + * This chipID is used in magnetometer driver to invet co-ordinates. + */ + status = i2c_smbus_xfer(adap, i2c_info.addr , 0 , + I2C_SMBUS_READ, 0x0F , + I2C_SMBUS_BYTE_DATA, &data); + if (status < 0) { + pr_err(__FILE__ ": failed to read 0x0F register\n"); + } + else + lsm303dlh_pdata.chip_id = data.byte; i2c_put_adapter(adap); } @@ -166,20 +185,24 @@ static int __init mop500_sensors_init(void) lsm303dlh_pdata.irq_m = GPIO_MAGNET_DRDY; } - mop500_sensors_i2c_add(2, mop500_i2c2_devices, - ARRAY_SIZE(mop500_i2c2_devices)); - if (machine_is_snowball()) { if (cpu_is_u8500v21()) /* This is ugly but we cant know what address * to use */ mop500_sensors_probe_add_lsm303dlh_a(); - else /* Add the accelerometer with new addr */ + else { + /* Add the accelerometer with new addr */ mop500_sensors_i2c_add(2, snowball_i2c2_devices, ARRAY_SIZE(snowball_i2c2_devices)); + /* For 0x19 accelerometer chip_id is 51*/ + lsm303dlh_pdata.chip_id = 51; + } } else /* none snowball have the old addr */ mop500_sensors_i2c_add(2, mop500_2_i2c2_devices, ARRAY_SIZE(mop500_2_i2c2_devices)); + + mop500_sensors_i2c_add(2, mop500_i2c2_devices, + ARRAY_SIZE(mop500_i2c2_devices)); return 0; } -- cgit v1.2.3 From 3e18d1bb698aa4e992e548007c2ca050aeedb2e5 Mon Sep 17 00:00:00 2001 From: Philippe Langlais Date: Wed, 15 Feb 2012 11:09:52 +0100 Subject: lsm303dlhc: Include Signed-off-by: Philippe Langlais --- drivers/hwmon/lsm303dlhc_a.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/hwmon/lsm303dlhc_a.c b/drivers/hwmon/lsm303dlhc_a.c index 8b7e2fe37b9..7d34e76731d 100644 --- a/drivers/hwmon/lsm303dlhc_a.c +++ b/drivers/hwmon/lsm303dlhc_a.c @@ -6,6 +6,7 @@ * Licence terms: GNU General Public Licence (GPL) version 2 */ +#include #include #include #include -- cgit v1.2.3