Commit 1da9e1c0 authored by Rui Miguel Silva's avatar Rui Miguel Silva Committed by Greg Kroah-Hartman

usb: isp1760: move to regmap for register access

Rework access to registers and memory to use regmap framework.
No change in current feature or way of work is intended with this
change.

This will allow to reuse this driver with other IP of this family,
for example isp1763, with little changes and effort.
Signed-off-by: default avatarRui Miguel Silva <rui.silva@linaro.org>
Link: https://lore.kernel.org/r/20210513084717.2487366-3-rui.silva@linaro.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent abfabc8a
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
config USB_ISP1760 config USB_ISP1760
tristate "NXP ISP 1760/1761 support" tristate "NXP ISP 1760/1761 support"
depends on USB || USB_GADGET depends on USB || USB_GADGET
select REGMAP_MMIO
help help
Say Y or M here if your system as an ISP1760 USB host controller Say Y or M here if your system as an ISP1760 USB host controller
or an ISP1761 USB dual-role controller. or an ISP1761 USB dual-role controller.
......
This diff is collapsed.
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#define _ISP1760_CORE_H_ #define _ISP1760_CORE_H_
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/regmap.h>
#include "isp1760-hcd.h" #include "isp1760-hcd.h"
#include "isp1760-udc.h" #include "isp1760-udc.h"
...@@ -38,7 +39,6 @@ struct gpio_desc; ...@@ -38,7 +39,6 @@ struct gpio_desc;
struct isp1760_device { struct isp1760_device {
struct device *dev; struct device *dev;
void __iomem *regs;
unsigned int devflags; unsigned int devflags;
struct gpio_desc *rst_gpio; struct gpio_desc *rst_gpio;
...@@ -52,14 +52,42 @@ void isp1760_unregister(struct device *dev); ...@@ -52,14 +52,42 @@ void isp1760_unregister(struct device *dev);
void isp1760_set_pullup(struct isp1760_device *isp, bool enable); void isp1760_set_pullup(struct isp1760_device *isp, bool enable);
static inline u32 isp1760_read32(void __iomem *base, u32 reg) static inline u32 isp1760_field_read(struct regmap_field **fields, u32 field)
{ {
return readl(base + reg); unsigned int val;
regmap_field_read(fields[field], &val);
return val;
}
static inline void isp1760_field_write(struct regmap_field **fields, u32 field,
u32 val)
{
regmap_field_write(fields[field], val);
}
static inline void isp1760_field_set(struct regmap_field **fields, u32 field)
{
isp1760_field_write(fields, field, 0xFFFFFFFF);
} }
static inline void isp1760_write32(void __iomem *base, u32 reg, u32 val) static inline void isp1760_field_clear(struct regmap_field **fields, u32 field)
{ {
writel(val, base + reg); isp1760_field_write(fields, field, 0);
} }
static inline u32 isp1760_reg_read(struct regmap *regs, u32 reg)
{
unsigned int val;
regmap_read(regs, reg, &val);
return val;
}
static inline void isp1760_reg_write(struct regmap *regs, u32 reg, u32 val)
{
regmap_write(regs, reg, val);
}
#endif #endif
This diff is collapsed.
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
#define _ISP1760_HCD_H_ #define _ISP1760_HCD_H_
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/regmap.h>
#include "isp1760-regs.h"
struct isp1760_qh; struct isp1760_qh;
struct isp1760_qtd; struct isp1760_qtd;
...@@ -48,10 +51,13 @@ enum isp1760_queue_head_types { ...@@ -48,10 +51,13 @@ enum isp1760_queue_head_types {
}; };
struct isp1760_hcd { struct isp1760_hcd {
#ifdef CONFIG_USB_ISP1760_HCD
struct usb_hcd *hcd; struct usb_hcd *hcd;
u32 hcs_params; void __iomem *base;
struct regmap *regs;
struct regmap_field *fields[HC_FIELD_MAX];
spinlock_t lock; spinlock_t lock;
struct isp1760_slotinfo atl_slots[32]; struct isp1760_slotinfo atl_slots[32];
int atl_done_map; int atl_done_map;
...@@ -66,20 +72,18 @@ struct isp1760_hcd { ...@@ -66,20 +72,18 @@ struct isp1760_hcd {
unsigned i_thresh; unsigned i_thresh;
unsigned long reset_done; unsigned long reset_done;
unsigned long next_statechange; unsigned long next_statechange;
#endif
}; };
#ifdef CONFIG_USB_ISP1760_HCD #ifdef CONFIG_USB_ISP1760_HCD
int isp1760_hcd_register(struct isp1760_hcd *priv, void __iomem *regs, int isp1760_hcd_register(struct isp1760_hcd *priv, struct resource *mem,
struct resource *mem, int irq, unsigned long irqflags, int irq, unsigned long irqflags, struct device *dev);
struct device *dev);
void isp1760_hcd_unregister(struct isp1760_hcd *priv); void isp1760_hcd_unregister(struct isp1760_hcd *priv);
int isp1760_init_kmem_once(void); int isp1760_init_kmem_once(void);
void isp1760_deinit_kmem_cache(void); void isp1760_deinit_kmem_cache(void);
#else #else
static inline int isp1760_hcd_register(struct isp1760_hcd *priv, static inline int isp1760_hcd_register(struct isp1760_hcd *priv,
void __iomem *regs, struct resource *mem, struct resource *mem,
int irq, unsigned long irqflags, int irq, unsigned long irqflags,
struct device *dev) struct device *dev)
{ {
......
...@@ -75,9 +75,9 @@ static int isp1761_pci_init(struct pci_dev *dev) ...@@ -75,9 +75,9 @@ static int isp1761_pci_init(struct pci_dev *dev)
/*by default host is in 16bit mode, so /*by default host is in 16bit mode, so
* io operations at this stage must be 16 bit * io operations at this stage must be 16 bit
* */ * */
writel(0xface, iobase + HC_SCRATCH_REG); writel(0xface, iobase + ISP176x_HC_SCRATCH);
udelay(100); udelay(100);
reg_data = readl(iobase + HC_SCRATCH_REG) & 0x0000ffff; reg_data = readl(iobase + ISP176x_HC_SCRATCH) & 0x0000ffff;
retry_count--; retry_count--;
} }
......
This diff is collapsed.
This diff is collapsed.
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/usb/gadget.h> #include <linux/usb/gadget.h>
#include "isp1760-regs.h"
struct isp1760_device; struct isp1760_device;
struct isp1760_udc; struct isp1760_udc;
...@@ -48,7 +50,7 @@ struct isp1760_ep { ...@@ -48,7 +50,7 @@ struct isp1760_ep {
* struct isp1760_udc - UDC state information * struct isp1760_udc - UDC state information
* irq: IRQ number * irq: IRQ number
* irqname: IRQ name (as passed to request_irq) * irqname: IRQ name (as passed to request_irq)
* regs: Base address of the UDC registers * regs: regmap for UDC registers
* driver: Gadget driver * driver: Gadget driver
* gadget: Gadget device * gadget: Gadget device
* lock: Protects driver, vbus_timer, ep, ep0_*, DC_EPINDEX register * lock: Protects driver, vbus_timer, ep, ep0_*, DC_EPINDEX register
...@@ -59,12 +61,13 @@ struct isp1760_ep { ...@@ -59,12 +61,13 @@ struct isp1760_ep {
* connected: Tracks gadget driver bus connection state * connected: Tracks gadget driver bus connection state
*/ */
struct isp1760_udc { struct isp1760_udc {
#ifdef CONFIG_USB_ISP1761_UDC
struct isp1760_device *isp; struct isp1760_device *isp;
int irq; int irq;
char *irqname; char *irqname;
void __iomem *regs;
struct regmap *regs;
struct regmap_field *fields[DC_FIELD_MAX];
struct usb_gadget_driver *driver; struct usb_gadget_driver *driver;
struct usb_gadget gadget; struct usb_gadget gadget;
...@@ -81,7 +84,6 @@ struct isp1760_udc { ...@@ -81,7 +84,6 @@ struct isp1760_udc {
bool connected; bool connected;
unsigned int devstatus; unsigned int devstatus;
#endif
}; };
#ifdef CONFIG_USB_ISP1761_UDC #ifdef CONFIG_USB_ISP1761_UDC
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment