Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Driver for the NXP ISP1760 chip
0004  *
0005  * Copyright 2021 Linaro, Rui Miguel Silva
0006  * Copyright 2014 Laurent Pinchart
0007  * Copyright 2007 Sebastian Siewior
0008  *
0009  * Contacts:
0010  *  Sebastian Siewior <bigeasy@linutronix.de>
0011  *  Laurent Pinchart <laurent.pinchart@ideasonboard.com>
0012  *  Rui Miguel Silva <rui.silva@linaro.org>
0013  */
0014 
0015 #ifndef _ISP1760_CORE_H_
0016 #define _ISP1760_CORE_H_
0017 
0018 #include <linux/ioport.h>
0019 #include <linux/regmap.h>
0020 
0021 #include "isp1760-hcd.h"
0022 #include "isp1760-udc.h"
0023 
0024 struct device;
0025 struct gpio_desc;
0026 
0027 /*
0028  * Device flags that can vary from board to board.  All of these
0029  * indicate the most "atypical" case, so that a devflags of 0 is
0030  * a sane default configuration.
0031  */
0032 #define ISP1760_FLAG_BUS_WIDTH_16   0x00000002 /* 16-bit data bus width */
0033 #define ISP1760_FLAG_PERIPHERAL_EN  0x00000004 /* Port 1 supports Peripheral mode*/
0034 #define ISP1760_FLAG_ANALOG_OC      0x00000008 /* Analog overcurrent */
0035 #define ISP1760_FLAG_DACK_POL_HIGH  0x00000010 /* DACK active high */
0036 #define ISP1760_FLAG_DREQ_POL_HIGH  0x00000020 /* DREQ active high */
0037 #define ISP1760_FLAG_ISP1761        0x00000040 /* Chip is ISP1761 */
0038 #define ISP1760_FLAG_INTR_POL_HIGH  0x00000080 /* Interrupt polarity active high */
0039 #define ISP1760_FLAG_INTR_EDGE_TRIG 0x00000100 /* Interrupt edge triggered */
0040 #define ISP1760_FLAG_ISP1763        0x00000200 /* Chip is ISP1763 */
0041 #define ISP1760_FLAG_BUS_WIDTH_8    0x00000400 /* 8-bit data bus width */
0042 
0043 struct isp1760_device {
0044     struct device *dev;
0045 
0046     unsigned int devflags;
0047     struct gpio_desc *rst_gpio;
0048 
0049     struct isp1760_hcd hcd;
0050     struct isp1760_udc udc;
0051 };
0052 
0053 int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
0054              struct device *dev, unsigned int devflags);
0055 void isp1760_unregister(struct device *dev);
0056 
0057 void isp1760_set_pullup(struct isp1760_device *isp, bool enable);
0058 
0059 static inline u32 isp1760_field_read(struct regmap_field **fields, u32 field)
0060 {
0061     unsigned int val;
0062 
0063     regmap_field_read(fields[field], &val);
0064 
0065     return val;
0066 }
0067 
0068 static inline void isp1760_field_write(struct regmap_field **fields, u32 field,
0069                        u32 val)
0070 {
0071     regmap_field_write(fields[field], val);
0072 }
0073 
0074 static inline void isp1760_field_set(struct regmap_field **fields, u32 field)
0075 {
0076     isp1760_field_write(fields, field, 0xFFFFFFFF);
0077 }
0078 
0079 static inline void isp1760_field_clear(struct regmap_field **fields, u32 field)
0080 {
0081     isp1760_field_write(fields, field, 0);
0082 }
0083 
0084 static inline u32 isp1760_reg_read(struct regmap *regs, u32 reg)
0085 {
0086     unsigned int val;
0087 
0088     regmap_read(regs, reg, &val);
0089 
0090     return val;
0091 }
0092 
0093 static inline void isp1760_reg_write(struct regmap *regs, u32 reg, u32 val)
0094 {
0095     regmap_write(regs, reg, val);
0096 }
0097 #endif