linux/drivers/phy/motorola/phy-cpcap-usb.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Motorola CPCAP PMIC USB PHY driver
 * Copyright (C) 2017 Tony Lindgren <[email protected]>
 *
 * Some parts based on earlier Motorola Linux kernel tree code in
 * board-mapphone-usb.c and cpcap-usb-det.c:
 * Copyright (C) 2007 - 2011 Motorola, Inc.
 */

#include <linux/atomic.h>
#include <linux/clk.h>
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/iio/consumer.h>
#include <linux/pinctrl/consumer.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
#include <linux/slab.h>

#include <linux/gpio/consumer.h>
#include <linux/mfd/motorola-cpcap.h>
#include <linux/phy/omap_usb.h>
#include <linux/phy/phy.h>
#include <linux/regulator/consumer.h>
#include <linux/usb/musb.h>

/* CPCAP_REG_USBC1 register bits */
#define CPCAP_BIT_IDPULSE
#define CPCAP_BIT_ID100KPU
#define CPCAP_BIT_IDPUCNTRL
#define CPCAP_BIT_IDPU
#define CPCAP_BIT_IDPD
#define CPCAP_BIT_VBUSCHRGTMR3
#define CPCAP_BIT_VBUSCHRGTMR2
#define CPCAP_BIT_VBUSCHRGTMR1
#define CPCAP_BIT_VBUSCHRGTMR0
#define CPCAP_BIT_VBUSPU
#define CPCAP_BIT_VBUSPD
#define CPCAP_BIT_DMPD
#define CPCAP_BIT_DPPD
#define CPCAP_BIT_DM1K5PU
#define CPCAP_BIT_DP1K5PU
#define CPCAP_BIT_DP150KPU

/* CPCAP_REG_USBC2 register bits */
#define CPCAP_BIT_ZHSDRV1
#define CPCAP_BIT_ZHSDRV0
#define CPCAP_BIT_DPLLCLKREQ
#define CPCAP_BIT_SE0CONN
#define CPCAP_BIT_UARTTXTRI
#define CPCAP_BIT_UARTSWAP
#define CPCAP_BIT_UARTMUX1
#define CPCAP_BIT_UARTMUX0
#define CPCAP_BIT_ULPISTPLOW
#define CPCAP_BIT_TXENPOL
#define CPCAP_BIT_USBXCVREN
#define CPCAP_BIT_USBCNTRL
#define CPCAP_BIT_USBSUSPEND
#define CPCAP_BIT_EMUMODE2
#define CPCAP_BIT_EMUMODE1
#define CPCAP_BIT_EMUMODE0

/* CPCAP_REG_USBC3 register bits */
#define CPCAP_BIT_SPARE_898_15
#define CPCAP_BIT_IHSTX03
#define CPCAP_BIT_IHSTX02
#define CPCAP_BIT_IHSTX01
#define CPCAP_BIT_IHSTX0
#define CPCAP_BIT_IDPU_SPI
#define CPCAP_BIT_UNUSED_898_9
#define CPCAP_BIT_VBUSSTBY_EN
#define CPCAP_BIT_VBUSEN_SPI
#define CPCAP_BIT_VBUSPU_SPI
#define CPCAP_BIT_VBUSPD_SPI
#define CPCAP_BIT_DMPD_SPI
#define CPCAP_BIT_DPPD_SPI
#define CPCAP_BIT_SUSPEND_SPI
#define CPCAP_BIT_PU_SPI
#define CPCAP_BIT_ULPI_SPI_SEL

struct cpcap_usb_ints_state {};

enum cpcap_gpio_mode {};

struct cpcap_phy_ddata {};

static bool cpcap_usb_vbus_valid(struct cpcap_phy_ddata *ddata)
{}

static int cpcap_usb_phy_set_host(struct usb_otg *otg, struct usb_bus *host)
{}

static int cpcap_usb_phy_set_peripheral(struct usb_otg *otg,
					struct usb_gadget *gadget)
{}

static const struct phy_ops ops =;

static int cpcap_phy_get_ints_state(struct cpcap_phy_ddata *ddata,
				    struct cpcap_usb_ints_state *s)
{}

static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata);
static int cpcap_usb_set_usb_mode(struct cpcap_phy_ddata *ddata);

static void cpcap_usb_try_musb_mailbox(struct cpcap_phy_ddata *ddata,
				       enum musb_vbus_id_status status)
{}

static void cpcap_usb_detect(struct work_struct *work)
{}

static irqreturn_t cpcap_phy_irq_thread(int irq, void *data)
{}

static int cpcap_usb_init_irq(struct platform_device *pdev,
			      struct cpcap_phy_ddata *ddata,
			      const char *name)
{}

static const char * const cpcap_phy_irqs[] =;

static int cpcap_usb_init_interrupts(struct platform_device *pdev,
				     struct cpcap_phy_ddata *ddata)
{}

/*
 * Optional pins and modes. At least Motorola mapphone devices
 * are using two GPIOs and dynamic pinctrl to multiplex PHY pins
 * to UART, ULPI or UTMI mode.
 */

static int cpcap_usb_gpio_set_mode(struct cpcap_phy_ddata *ddata,
				   enum cpcap_gpio_mode mode)
{}

static int cpcap_usb_set_uart_mode(struct cpcap_phy_ddata *ddata)
{}

static int cpcap_usb_set_usb_mode(struct cpcap_phy_ddata *ddata)
{}

static int cpcap_usb_init_optional_pins(struct cpcap_phy_ddata *ddata)
{}

static void cpcap_usb_init_optional_gpios(struct cpcap_phy_ddata *ddata)
{}

static int cpcap_usb_init_iio(struct cpcap_phy_ddata *ddata)
{}

#ifdef CONFIG_OF
static const struct of_device_id cpcap_usb_phy_id_table[] =;
MODULE_DEVICE_TABLE(of, cpcap_usb_phy_id_table);
#endif

static int cpcap_usb_phy_probe(struct platform_device *pdev)
{}

static void cpcap_usb_phy_remove(struct platform_device *pdev)
{}

static struct platform_driver cpcap_usb_phy_driver =;

module_platform_driver();

MODULE_ALIAS();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();