Allen Martin | fc468d8 | 2016-11-15 17:57:52 -0800 | [diff] [blame] | 1 | From 3fe2a383c4675345cbd14f18131b6461ca36bd02 Mon Sep 17 00:00:00 2001 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 2 | From: Alexandre Belloni <alexandre.belloni@free-electrons.com> |
| 3 | Date: Wed, 30 Sep 2015 12:57:10 +0200 |
Allen Martin | fc468d8 | 2016-11-15 17:57:52 -0800 | [diff] [blame] | 4 | Subject: [PATCH 318/351] usb: gadget: atmel: access the PMC using regmap |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 5 | X-NVConfidentiality: public |
| 6 | |
| 7 | Use regmap to access the PMC to avoid using at91_pmc_read and |
| 8 | at91_pmc_write. |
| 9 | |
| 10 | Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> |
| 11 | Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com> |
| 12 | Acked-by: Felipe Balbi <balbi@ti.com> |
| 13 | Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 14 | --- |
| 15 | drivers/usb/gadget/udc/atmel_usba_udc.c | 20 ++++++++++---------- |
| 16 | drivers/usb/gadget/udc/atmel_usba_udc.h | 2 ++ |
| 17 | 2 files changed, 12 insertions(+), 10 deletions(-) |
| 18 | |
| 19 | diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c |
| 20 | index f92f5aff0dd5..f9bba26e3655 100644 |
| 21 | --- a/drivers/usb/gadget/udc/atmel_usba_udc.c |
| 22 | +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c |
| 23 | @@ -17,7 +17,9 @@ |
| 24 | #include <linux/device.h> |
| 25 | #include <linux/dma-mapping.h> |
| 26 | #include <linux/list.h> |
| 27 | +#include <linux/mfd/syscon.h> |
| 28 | #include <linux/platform_device.h> |
| 29 | +#include <linux/regmap.h> |
| 30 | #include <linux/usb/ch9.h> |
| 31 | #include <linux/usb/gadget.h> |
| 32 | #include <linux/usb/atmel_usba_udc.h> |
| 33 | @@ -1888,20 +1890,15 @@ static int atmel_usba_stop(struct usb_gadget *gadget) |
| 34 | #ifdef CONFIG_OF |
| 35 | static void at91sam9rl_toggle_bias(struct usba_udc *udc, int is_on) |
| 36 | { |
| 37 | - unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR); |
| 38 | - |
| 39 | - if (is_on) |
| 40 | - at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN); |
| 41 | - else |
| 42 | - at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN)); |
| 43 | + regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN, |
| 44 | + is_on ? AT91_PMC_BIASEN : 0); |
| 45 | } |
| 46 | |
| 47 | static void at91sam9g45_pulse_bias(struct usba_udc *udc) |
| 48 | { |
| 49 | - unsigned int uckr = at91_pmc_read(AT91_CKGR_UCKR); |
| 50 | - |
| 51 | - at91_pmc_write(AT91_CKGR_UCKR, uckr & ~(AT91_PMC_BIASEN)); |
| 52 | - at91_pmc_write(AT91_CKGR_UCKR, uckr | AT91_PMC_BIASEN); |
| 53 | + regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN, 0); |
| 54 | + regmap_update_bits(udc->pmc, AT91_CKGR_UCKR, AT91_PMC_BIASEN, |
| 55 | + AT91_PMC_BIASEN); |
| 56 | } |
| 57 | |
| 58 | static const struct usba_udc_errata at91sam9rl_errata = { |
| 59 | @@ -1938,6 +1935,9 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, |
| 60 | return ERR_PTR(-EINVAL); |
| 61 | |
| 62 | udc->errata = match->data; |
| 63 | + udc->pmc = syscon_regmap_lookup_by_compatible("atmel,at91sam9g45-pmc"); |
| 64 | + if (udc->errata && IS_ERR(udc->pmc)) |
| 65 | + return ERR_CAST(udc->pmc); |
| 66 | |
| 67 | udc->num_ep = 0; |
| 68 | |
| 69 | diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.h b/drivers/usb/gadget/udc/atmel_usba_udc.h |
| 70 | index ea448a344767..3e1c9d589dfa 100644 |
| 71 | --- a/drivers/usb/gadget/udc/atmel_usba_udc.h |
| 72 | +++ b/drivers/usb/gadget/udc/atmel_usba_udc.h |
| 73 | @@ -354,6 +354,8 @@ struct usba_udc { |
| 74 | struct dentry *debugfs_root; |
| 75 | struct dentry *debugfs_regs; |
| 76 | #endif |
| 77 | + |
| 78 | + struct regmap *pmc; |
| 79 | }; |
| 80 | |
| 81 | static inline struct usba_ep *to_usba_ep(struct usb_ep *ep) |
| 82 | -- |
Allen Martin | fc468d8 | 2016-11-15 17:57:52 -0800 | [diff] [blame] | 83 | 2.10.1 |
Allen Martin | 685e0f8 | 2016-07-26 19:34:29 -0700 | [diff] [blame] | 84 | |