2020-04-04 09:38:08 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2015-01-20 22:55:57 +00:00
|
|
|
/*
|
|
|
|
* Driver for the NXP ISP1760 chip
|
|
|
|
*
|
2021-05-13 08:47:15 +00:00
|
|
|
* Copyright 2021 Linaro, Rui Miguel Silva
|
2015-01-20 22:55:57 +00:00
|
|
|
* Copyright 2014 Laurent Pinchart
|
|
|
|
* Copyright 2007 Sebastian Siewior
|
|
|
|
*
|
|
|
|
* Contacts:
|
|
|
|
* Sebastian Siewior <bigeasy@linutronix.de>
|
|
|
|
* Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
2021-05-13 08:47:15 +00:00
|
|
|
* Rui Miguel Silva <rui.silva@linaro.org>
|
2015-01-20 22:55:57 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _ISP1760_CORE_H_
|
|
|
|
#define _ISP1760_CORE_H_
|
|
|
|
|
|
|
|
#include <linux/ioport.h>
|
2021-05-13 08:47:10 +00:00
|
|
|
#include <linux/regmap.h>
|
2015-01-20 22:55:57 +00:00
|
|
|
|
|
|
|
#include "isp1760-hcd.h"
|
2015-01-20 22:56:01 +00:00
|
|
|
#include "isp1760-udc.h"
|
2015-01-20 22:55:57 +00:00
|
|
|
|
2015-01-20 22:55:59 +00:00
|
|
|
struct device;
|
|
|
|
struct gpio_desc;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Device flags that can vary from board to board. All of these
|
|
|
|
* indicate the most "atypical" case, so that a devflags of 0 is
|
|
|
|
* a sane default configuration.
|
|
|
|
*/
|
|
|
|
#define ISP1760_FLAG_BUS_WIDTH_16 0x00000002 /* 16-bit data bus width */
|
2021-05-13 08:47:14 +00:00
|
|
|
#define ISP1760_FLAG_PERIPHERAL_EN 0x00000004 /* Port 1 supports Peripheral mode*/
|
2015-01-20 22:55:59 +00:00
|
|
|
#define ISP1760_FLAG_ANALOG_OC 0x00000008 /* Analog overcurrent */
|
|
|
|
#define ISP1760_FLAG_DACK_POL_HIGH 0x00000010 /* DACK active high */
|
|
|
|
#define ISP1760_FLAG_DREQ_POL_HIGH 0x00000020 /* DREQ active high */
|
|
|
|
#define ISP1760_FLAG_ISP1761 0x00000040 /* Chip is ISP1761 */
|
|
|
|
#define ISP1760_FLAG_INTR_POL_HIGH 0x00000080 /* Interrupt polarity active high */
|
|
|
|
#define ISP1760_FLAG_INTR_EDGE_TRIG 0x00000100 /* Interrupt edge triggered */
|
2021-05-13 08:47:15 +00:00
|
|
|
#define ISP1760_FLAG_ISP1763 0x00000200 /* Chip is ISP1763 */
|
|
|
|
#define ISP1760_FLAG_BUS_WIDTH_8 0x00000400 /* 8-bit data bus width */
|
2015-01-20 22:55:59 +00:00
|
|
|
|
2015-01-20 22:55:57 +00:00
|
|
|
struct isp1760_device {
|
2015-01-20 22:55:59 +00:00
|
|
|
struct device *dev;
|
|
|
|
|
|
|
|
unsigned int devflags;
|
|
|
|
struct gpio_desc *rst_gpio;
|
2015-01-20 22:55:57 +00:00
|
|
|
|
|
|
|
struct isp1760_hcd hcd;
|
2015-01-20 22:56:01 +00:00
|
|
|
struct isp1760_udc udc;
|
2015-01-20 22:55:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
int isp1760_register(struct resource *mem, int irq, unsigned long irqflags,
|
|
|
|
struct device *dev, unsigned int devflags);
|
|
|
|
void isp1760_unregister(struct device *dev);
|
|
|
|
|
2015-01-20 22:56:01 +00:00
|
|
|
void isp1760_set_pullup(struct isp1760_device *isp, bool enable);
|
|
|
|
|
2021-05-13 08:47:10 +00:00
|
|
|
static inline u32 isp1760_field_read(struct regmap_field **fields, u32 field)
|
2015-01-20 22:55:59 +00:00
|
|
|
{
|
2021-05-13 08:47:10 +00:00
|
|
|
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);
|
2015-01-20 22:55:59 +00:00
|
|
|
}
|
|
|
|
|
2021-05-13 08:47:10 +00:00
|
|
|
static inline void isp1760_field_clear(struct regmap_field **fields, u32 field)
|
2015-01-20 22:55:59 +00:00
|
|
|
{
|
2021-05-13 08:47:10 +00:00
|
|
|
isp1760_field_write(fields, field, 0);
|
2015-01-20 22:55:59 +00:00
|
|
|
}
|
|
|
|
|
2021-05-13 08:47:10 +00:00
|
|
|
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);
|
|
|
|
}
|
2015-01-20 22:55:57 +00:00
|
|
|
#endif
|