Commit 8848ff42 authored by Lee Jones's avatar Lee Jones
Browse files

Merge branches 'ib-mfd-leds-4.16', 'ib-mfd-memstick-misc-mmc-4.16',...

Merge branches 'ib-mfd-leds-4.16', 'ib-mfd-memstick-misc-mmc-4.16', 'ib-mfd-platform-4.16' and 'ib-mfd-tty-watchdog-4.16', tag 'ib-extcon-mfd-4.16-1' into ibs-for-mfd-merged

Immutable branch for both MFD and EXTCON tree.
Loading
Loading
Loading
Loading
+39 −0
Original line number Original line Diff line number Diff line
Zodiac Inflight Innovations RAVE Supervisory Processor Watchdog Bindings

RAVE SP watchdog device is a "MFD cell" device corresponding to
watchdog functionality of RAVE Supervisory Processor. It is expected
that its Device Tree node is specified as a child of the node
corresponding to the parent RAVE SP device (as documented in
Documentation/devicetree/bindings/mfd/zii,rave-sp.txt)

Required properties:

- compatible: Depending on wire protocol implemented by RAVE SP
  firmware, should be one of:
	- "zii,rave-sp-watchdog"
	- "zii,rave-sp-watchdog-legacy"

Optional properties:

- wdt-timeout:	Two byte nvmem cell specified as per
		Documentation/devicetree/bindings/nvmem/nvmem.txt

Example:

	rave-sp {
		compatible = "zii,rave-sp-rdu1";
		current-speed = <38400>;

		eeprom {
			wdt_timeout: wdt-timeout@8E {
				reg = <0x8E 2>;
			};
		};

		watchdog {
			compatible = "zii,rave-sp-watchdog";
			nvmem-cells = <&wdt_timeout>;
			nvmem-cell-names = "wdt-timeout";
		};
	}
+3 −0
Original line number Original line Diff line number Diff line
@@ -384,6 +384,9 @@ RESET
  devm_reset_control_get()
  devm_reset_control_get()
  devm_reset_controller_register()
  devm_reset_controller_register()


SERDEV
  devm_serdev_device_open()

SLAVE DMA ENGINE
SLAVE DMA ENGINE
  devm_acpi_dma_controller_register()
  devm_acpi_dma_controller_register()


+4 −35
Original line number Original line Diff line number Diff line
@@ -24,8 +24,6 @@
#include <linux/notifier.h>
#include <linux/notifier.h>
#include <linux/extcon-provider.h>
#include <linux/extcon-provider.h>
#include <linux/regmap.h>
#include <linux/regmap.h>
#include <linux/gpio.h>
#include <linux/gpio/consumer.h>
#include <linux/mfd/axp20x.h>
#include <linux/mfd/axp20x.h>


/* Power source status register */
/* Power source status register */
@@ -79,11 +77,6 @@ enum axp288_extcon_reg {
	AXP288_BC_DET_STAT_REG		= 0x2f,
	AXP288_BC_DET_STAT_REG		= 0x2f,
};
};


enum axp288_mux_select {
	EXTCON_GPIO_MUX_SEL_PMIC = 0,
	EXTCON_GPIO_MUX_SEL_SOC,
};

enum axp288_extcon_irq {
enum axp288_extcon_irq {
	VBUS_FALLING_IRQ = 0,
	VBUS_FALLING_IRQ = 0,
	VBUS_RISING_IRQ,
	VBUS_RISING_IRQ,
@@ -104,10 +97,8 @@ struct axp288_extcon_info {
	struct device *dev;
	struct device *dev;
	struct regmap *regmap;
	struct regmap *regmap;
	struct regmap_irq_chip_data *regmap_irqc;
	struct regmap_irq_chip_data *regmap_irqc;
	struct gpio_desc *gpio_mux_cntl;
	int irq[EXTCON_IRQ_END];
	int irq[EXTCON_IRQ_END];
	struct extcon_dev *edev;
	struct extcon_dev *edev;
	struct notifier_block extcon_nb;
	unsigned int previous_cable;
	unsigned int previous_cable;
};
};


@@ -197,15 +188,6 @@ static int axp288_handle_chrg_det_event(struct axp288_extcon_info *info)
	}
	}


no_vbus:
no_vbus:
	/*
	 * If VBUS is absent Connect D+/D- lines to PMIC for BC
	 * detection. Else connect them to SOC for USB communication.
	 */
	if (info->gpio_mux_cntl)
		gpiod_set_value(info->gpio_mux_cntl,
			vbus_attach ? EXTCON_GPIO_MUX_SEL_SOC
					: EXTCON_GPIO_MUX_SEL_PMIC);

	extcon_set_state_sync(info->edev, info->previous_cable, false);
	extcon_set_state_sync(info->edev, info->previous_cable, false);
	if (info->previous_cable == EXTCON_CHG_USB_SDP)
	if (info->previous_cable == EXTCON_CHG_USB_SDP)
		extcon_set_state_sync(info->edev, EXTCON_USB, false);
		extcon_set_state_sync(info->edev, EXTCON_USB, false);
@@ -253,8 +235,7 @@ static int axp288_extcon_probe(struct platform_device *pdev)
{
{
	struct axp288_extcon_info *info;
	struct axp288_extcon_info *info;
	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
	struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
	struct axp288_extcon_pdata *pdata = pdev->dev.platform_data;
	int ret, i, pirq;
	int ret, i, pirq, gpio;


	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
	info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL);
	if (!info)
	if (!info)
@@ -264,8 +245,6 @@ static int axp288_extcon_probe(struct platform_device *pdev)
	info->regmap = axp20x->regmap;
	info->regmap = axp20x->regmap;
	info->regmap_irqc = axp20x->regmap_irqc;
	info->regmap_irqc = axp20x->regmap_irqc;
	info->previous_cable = EXTCON_NONE;
	info->previous_cable = EXTCON_NONE;
	if (pdata)
		info->gpio_mux_cntl = pdata->gpio_mux_cntl;


	platform_set_drvdata(pdev, info);
	platform_set_drvdata(pdev, info);


@@ -286,21 +265,11 @@ static int axp288_extcon_probe(struct platform_device *pdev)
		return ret;
		return ret;
	}
	}


	/* Set up gpio control for USB Mux */
	if (info->gpio_mux_cntl) {
		gpio = desc_to_gpio(info->gpio_mux_cntl);
		ret = devm_gpio_request(&pdev->dev, gpio, "USB_MUX");
		if (ret < 0) {
			dev_err(&pdev->dev,
				"failed to request the gpio=%d\n", gpio);
			return ret;
		}
		gpiod_direction_output(info->gpio_mux_cntl,
						EXTCON_GPIO_MUX_SEL_PMIC);
	}

	for (i = 0; i < EXTCON_IRQ_END; i++) {
	for (i = 0; i < EXTCON_IRQ_END; i++) {
		pirq = platform_get_irq(pdev, i);
		pirq = platform_get_irq(pdev, i);
		if (pirq < 0)
			return pirq;

		info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq);
		info->irq[i] = regmap_irq_get_virq(info->regmap_irqc, pirq);
		if (info->irq[i] < 0) {
		if (info->irq[i] < 0) {
			dev_err(&pdev->dev,
			dev_err(&pdev->dev,
+138 −4
Original line number Original line Diff line number Diff line
@@ -34,16 +34,26 @@ struct cros_ec_extcon_info {


	struct notifier_block notifier;
	struct notifier_block notifier;


	unsigned int dr; /* data role */
	bool pr; /* power role (true if VBUS enabled) */
	bool dp; /* DisplayPort enabled */
	bool dp; /* DisplayPort enabled */
	bool mux; /* SuperSpeed (usb3) enabled */
	bool mux; /* SuperSpeed (usb3) enabled */
	unsigned int power_type;
	unsigned int power_type;
};
};


static const unsigned int usb_type_c_cable[] = {
static const unsigned int usb_type_c_cable[] = {
	EXTCON_USB,
	EXTCON_USB_HOST,
	EXTCON_DISP_DP,
	EXTCON_DISP_DP,
	EXTCON_NONE,
	EXTCON_NONE,
};
};


enum usb_data_roles {
	DR_NONE,
	DR_HOST,
	DR_DEVICE,
};

/**
/**
 * cros_ec_pd_command() - Send a command to the EC.
 * cros_ec_pd_command() - Send a command to the EC.
 * @info: pointer to struct cros_ec_extcon_info
 * @info: pointer to struct cros_ec_extcon_info
@@ -150,6 +160,7 @@ static int cros_ec_usb_get_role(struct cros_ec_extcon_info *info,
	pd_control.port = info->port_id;
	pd_control.port = info->port_id;
	pd_control.role = USB_PD_CTRL_ROLE_NO_CHANGE;
	pd_control.role = USB_PD_CTRL_ROLE_NO_CHANGE;
	pd_control.mux = USB_PD_CTRL_MUX_NO_CHANGE;
	pd_control.mux = USB_PD_CTRL_MUX_NO_CHANGE;
	pd_control.swap = USB_PD_CTRL_SWAP_NONE;
	ret = cros_ec_pd_command(info, EC_CMD_USB_PD_CONTROL, 1,
	ret = cros_ec_pd_command(info, EC_CMD_USB_PD_CONTROL, 1,
				 &pd_control, sizeof(pd_control),
				 &pd_control, sizeof(pd_control),
				 &resp, sizeof(resp));
				 &resp, sizeof(resp));
@@ -183,11 +194,72 @@ static int cros_ec_pd_get_num_ports(struct cros_ec_extcon_info *info)
	return resp.num_ports;
	return resp.num_ports;
}
}


static const char *cros_ec_usb_role_string(unsigned int role)
{
	return role == DR_NONE ? "DISCONNECTED" :
		(role == DR_HOST ? "DFP" : "UFP");
}

static const char *cros_ec_usb_power_type_string(unsigned int type)
{
	switch (type) {
	case USB_CHG_TYPE_NONE:
		return "USB_CHG_TYPE_NONE";
	case USB_CHG_TYPE_PD:
		return "USB_CHG_TYPE_PD";
	case USB_CHG_TYPE_PROPRIETARY:
		return "USB_CHG_TYPE_PROPRIETARY";
	case USB_CHG_TYPE_C:
		return "USB_CHG_TYPE_C";
	case USB_CHG_TYPE_BC12_DCP:
		return "USB_CHG_TYPE_BC12_DCP";
	case USB_CHG_TYPE_BC12_CDP:
		return "USB_CHG_TYPE_BC12_CDP";
	case USB_CHG_TYPE_BC12_SDP:
		return "USB_CHG_TYPE_BC12_SDP";
	case USB_CHG_TYPE_OTHER:
		return "USB_CHG_TYPE_OTHER";
	case USB_CHG_TYPE_VBUS:
		return "USB_CHG_TYPE_VBUS";
	case USB_CHG_TYPE_UNKNOWN:
		return "USB_CHG_TYPE_UNKNOWN";
	default:
		return "USB_CHG_TYPE_UNKNOWN";
	}
}

static bool cros_ec_usb_power_type_is_wall_wart(unsigned int type,
						unsigned int role)
{
	switch (type) {
	/* FIXME : Guppy, Donnettes, and other chargers will be miscategorized
	 * because they identify with USB_CHG_TYPE_C, but we can't return true
	 * here from that code because that breaks Suzy-Q and other kinds of
	 * USB Type-C cables and peripherals.
	 */
	case USB_CHG_TYPE_PROPRIETARY:
	case USB_CHG_TYPE_BC12_DCP:
		return true;
	case USB_CHG_TYPE_PD:
	case USB_CHG_TYPE_C:
	case USB_CHG_TYPE_BC12_CDP:
	case USB_CHG_TYPE_BC12_SDP:
	case USB_CHG_TYPE_OTHER:
	case USB_CHG_TYPE_VBUS:
	case USB_CHG_TYPE_UNKNOWN:
	case USB_CHG_TYPE_NONE:
	default:
		return false;
	}
}

static int extcon_cros_ec_detect_cable(struct cros_ec_extcon_info *info,
static int extcon_cros_ec_detect_cable(struct cros_ec_extcon_info *info,
				       bool force)
				       bool force)
{
{
	struct device *dev = info->dev;
	struct device *dev = info->dev;
	int role, power_type;
	int role, power_type;
	unsigned int dr = DR_NONE;
	bool pr = false;
	bool polarity = false;
	bool polarity = false;
	bool dp = false;
	bool dp = false;
	bool mux = false;
	bool mux = false;
@@ -206,9 +278,12 @@ static int extcon_cros_ec_detect_cable(struct cros_ec_extcon_info *info,
			dev_err(dev, "failed getting role err = %d\n", role);
			dev_err(dev, "failed getting role err = %d\n", role);
			return role;
			return role;
		}
		}
		dev_dbg(dev, "disconnected\n");
	} else {
	} else {
		int pd_mux_state;
		int pd_mux_state;


		dr = (role & PD_CTRL_RESP_ROLE_DATA) ? DR_HOST : DR_DEVICE;
		pr = (role & PD_CTRL_RESP_ROLE_POWER);
		pd_mux_state = cros_ec_usb_get_pd_mux_state(info);
		pd_mux_state = cros_ec_usb_get_pd_mux_state(info);
		if (pd_mux_state < 0)
		if (pd_mux_state < 0)
			pd_mux_state = USB_PD_MUX_USB_ENABLED;
			pd_mux_state = USB_PD_MUX_USB_ENABLED;
@@ -216,20 +291,62 @@ static int extcon_cros_ec_detect_cable(struct cros_ec_extcon_info *info,
		dp = pd_mux_state & USB_PD_MUX_DP_ENABLED;
		dp = pd_mux_state & USB_PD_MUX_DP_ENABLED;
		mux = pd_mux_state & USB_PD_MUX_USB_ENABLED;
		mux = pd_mux_state & USB_PD_MUX_USB_ENABLED;
		hpd = pd_mux_state & USB_PD_MUX_HPD_IRQ;
		hpd = pd_mux_state & USB_PD_MUX_HPD_IRQ;
	}


	if (force || info->dp != dp || info->mux != mux ||
		dev_dbg(dev,
		info->power_type != power_type) {
			"connected role 0x%x pwr type %d dr %d pr %d pol %d mux %d dp %d hpd %d\n",
			role, power_type, dr, pr, polarity, mux, dp, hpd);
	}


	/*
	 * When there is no USB host (e.g. USB PD charger),
	 * we are not really a UFP for the AP.
	 */
	if (dr == DR_DEVICE &&
	    cros_ec_usb_power_type_is_wall_wart(power_type, role))
		dr = DR_NONE;

	if (force || info->dr != dr || info->pr != pr || info->dp != dp ||
	    info->mux != mux || info->power_type != power_type) {
		bool host_connected = false, device_connected = false;

		dev_dbg(dev, "Type/Role switch! type = %s role = %s\n",
			cros_ec_usb_power_type_string(power_type),
			cros_ec_usb_role_string(dr));
		info->dr = dr;
		info->pr = pr;
		info->dp = dp;
		info->dp = dp;
		info->mux = mux;
		info->mux = mux;
		info->power_type = power_type;
		info->power_type = power_type;


		extcon_set_state(info->edev, EXTCON_DISP_DP, dp);
		if (dr == DR_DEVICE)
			device_connected = true;
		else if (dr == DR_HOST)
			host_connected = true;


		extcon_set_state(info->edev, EXTCON_USB, device_connected);
		extcon_set_state(info->edev, EXTCON_USB_HOST, host_connected);
		extcon_set_state(info->edev, EXTCON_DISP_DP, dp);
		extcon_set_property(info->edev, EXTCON_USB,
				    EXTCON_PROP_USB_VBUS,
				    (union extcon_property_value)(int)pr);
		extcon_set_property(info->edev, EXTCON_USB_HOST,
				    EXTCON_PROP_USB_VBUS,
				    (union extcon_property_value)(int)pr);
		extcon_set_property(info->edev, EXTCON_USB,
				    EXTCON_PROP_USB_TYPEC_POLARITY,
				    (union extcon_property_value)(int)polarity);
		extcon_set_property(info->edev, EXTCON_USB_HOST,
				    EXTCON_PROP_USB_TYPEC_POLARITY,
				    (union extcon_property_value)(int)polarity);
		extcon_set_property(info->edev, EXTCON_DISP_DP,
		extcon_set_property(info->edev, EXTCON_DISP_DP,
				    EXTCON_PROP_USB_TYPEC_POLARITY,
				    EXTCON_PROP_USB_TYPEC_POLARITY,
				    (union extcon_property_value)(int)polarity);
				    (union extcon_property_value)(int)polarity);
		extcon_set_property(info->edev, EXTCON_USB,
				    EXTCON_PROP_USB_SS,
				    (union extcon_property_value)(int)mux);
		extcon_set_property(info->edev, EXTCON_USB_HOST,
				    EXTCON_PROP_USB_SS,
				    (union extcon_property_value)(int)mux);
		extcon_set_property(info->edev, EXTCON_DISP_DP,
		extcon_set_property(info->edev, EXTCON_DISP_DP,
				    EXTCON_PROP_USB_SS,
				    EXTCON_PROP_USB_SS,
				    (union extcon_property_value)(int)mux);
				    (union extcon_property_value)(int)mux);
@@ -237,6 +354,8 @@ static int extcon_cros_ec_detect_cable(struct cros_ec_extcon_info *info,
				    EXTCON_PROP_DISP_HPD,
				    EXTCON_PROP_DISP_HPD,
				    (union extcon_property_value)(int)hpd);
				    (union extcon_property_value)(int)hpd);


		extcon_sync(info->edev, EXTCON_USB);
		extcon_sync(info->edev, EXTCON_USB_HOST);
		extcon_sync(info->edev, EXTCON_DISP_DP);
		extcon_sync(info->edev, EXTCON_DISP_DP);


	} else if (hpd) {
	} else if (hpd) {
@@ -322,13 +441,28 @@ static int extcon_cros_ec_probe(struct platform_device *pdev)
		return ret;
		return ret;
	}
	}


	extcon_set_property_capability(info->edev, EXTCON_USB,
				       EXTCON_PROP_USB_VBUS);
	extcon_set_property_capability(info->edev, EXTCON_USB_HOST,
				       EXTCON_PROP_USB_VBUS);
	extcon_set_property_capability(info->edev, EXTCON_USB,
				       EXTCON_PROP_USB_TYPEC_POLARITY);
	extcon_set_property_capability(info->edev, EXTCON_USB_HOST,
				       EXTCON_PROP_USB_TYPEC_POLARITY);
	extcon_set_property_capability(info->edev, EXTCON_DISP_DP,
	extcon_set_property_capability(info->edev, EXTCON_DISP_DP,
				       EXTCON_PROP_USB_TYPEC_POLARITY);
				       EXTCON_PROP_USB_TYPEC_POLARITY);
	extcon_set_property_capability(info->edev, EXTCON_USB,
				       EXTCON_PROP_USB_SS);
	extcon_set_property_capability(info->edev, EXTCON_USB_HOST,
				       EXTCON_PROP_USB_SS);
	extcon_set_property_capability(info->edev, EXTCON_DISP_DP,
	extcon_set_property_capability(info->edev, EXTCON_DISP_DP,
				       EXTCON_PROP_USB_SS);
				       EXTCON_PROP_USB_SS);
	extcon_set_property_capability(info->edev, EXTCON_DISP_DP,
	extcon_set_property_capability(info->edev, EXTCON_DISP_DP,
				       EXTCON_PROP_DISP_HPD);
				       EXTCON_PROP_DISP_HPD);


	info->dr = DR_NONE;
	info->pr = false;

	platform_set_drvdata(pdev, info);
	platform_set_drvdata(pdev, info);


	/* Get PD events from the EC */
	/* Get PD events from the EC */
+1 −1
Original line number Original line Diff line number Diff line
@@ -106,7 +106,7 @@ static int pm8058_led_probe(struct platform_device *pdev)
	if (!led)
	if (!led)
		return -ENOMEM;
		return -ENOMEM;


	led->ledtype = (u32)of_device_get_match_data(&pdev->dev);
	led->ledtype = (u32)(unsigned long)of_device_get_match_data(&pdev->dev);


	map = dev_get_regmap(pdev->dev.parent, NULL);
	map = dev_get_regmap(pdev->dev.parent, NULL);
	if (!map) {
	if (!map) {
Loading