Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 64600e1b authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ci-bridge-spi: Add support for device-tree"

parents 1ff72517 b49e1f11
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
CI (CAM) Bridge Over SPI

Required properties:

- compatible: "smartv,cimax"
- reg: SPI chip-select
- spi-max-frequency: Max allowed frequency of SPI interface
- smartv,cimax-int-gpio: CIMax interrupt gpio pin
- smartv,cimax-rst-gpio: CIMax reset gpio pin

Example:

	spi@f9923000 {
	   ci-bridge-spi@0 {
			compatible = "smartv,cimax";
			reg = <0>;
			spi-max-frequency = <15000000>;
			smartv,cimax-int-gpio = <&msmgpio 133 0>;
			smartv,cimax-rst-gpio = <&ioexp_gpios 5 0>;
	   };
	};
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ renesas Renesas Electronics Corporation
samsung	Samsung Semiconductor
sbs	Smart Battery System
schindler	Schindler
smartv SmartV Ltd
stk	Sensortek Technology Corporation.(formerly Sitronix Technology Co., Ltd.)
shinetech	Shine Tech Corporation, Ltd.
sil	Silicon Image
+52 −9
Original line number Diff line number Diff line
@@ -27,7 +27,8 @@
#include <linux/uaccess.h>
#include <linux/gpio.h>
#include <linux/delay.h>

#include <linux/of.h>
#include <linux/of_gpio.h>
#include <linux/ci-bridge-spi.h>

#define CI_MAX_BUFFER_SIZE	(64 * 1024)
@@ -47,25 +48,67 @@ struct ci_bridge {

};

static struct of_device_id cibridge_match_table[] = {
	{.compatible = "smartv,cimax"},
	{}
};

static struct ci_bridge ci;

static int ci_bridge_spi_dt_to_pdata(struct spi_device *spi,
			struct ci_bridge_platform_data *pdata)
{
	struct device_node *node = spi->dev.of_node;

	pdata->reset_pin = of_get_named_gpio(node, "smartv,cimax-rst-gpio", 0);
	if (pdata->reset_pin < 0) {
		pr_err("%s: Could not find reset gpio, err %d\n",
			__func__, pdata->reset_pin);
		return -EINVAL;
	}

	pdata->interrupt_pin = of_get_named_gpio(node,
		"smartv,cimax-int-gpio", 0);
	if (pdata->interrupt_pin < 0) {
		pr_err("%s: Could not find interrupt gpio, err %d\n",
			__func__, pdata->reset_pin);
		return -EINVAL;
	}

	return 0;
}

static int ci_bridge_spi_probe(struct spi_device *spi)
{
	int ret;
	struct ci_bridge_platform_data *pdata;

	if (spi->dev.platform_data == NULL) {
	if (spi->dev.of_node) {
		struct ci_bridge_platform_data pdata;

		/* get information from device tree */
		ret = ci_bridge_spi_dt_to_pdata(spi, &pdata);
		if (ret < 0) {
			pr_err("%s: parsing DT failed %d\n", __func__, ret);
			return ret;
		}

		ci.gpio_reset_pin = pdata.reset_pin;
		ci.gpio_interrupt_pin = pdata.interrupt_pin;
	} else {
		struct ci_bridge_platform_data *pdata = spi->dev.platform_data;
		if (!pdata) {
			pr_err("%s: platform data is missing\n", __func__);
			return -EINVAL;
		}

		ci.gpio_reset_pin = pdata->reset_pin;
		ci.gpio_interrupt_pin = pdata->interrupt_pin;
	}

	ci.spi = spi;
	ci.num_opened = 0;
	mutex_init(&ci.lock);
	spi_set_drvdata(spi, &ci);
	pdata = spi->dev.platform_data;
	ci.gpio_reset_pin = pdata->reset_pin;
	ci.gpio_interrupt_pin = pdata->interrupt_pin;

	ret = gpio_request(ci.gpio_reset_pin, "ci_bridge_spi");
	if (ret) {
@@ -120,6 +163,7 @@ static int ci_bridge_spi_remove(struct spi_device *spi)
static struct spi_driver ci_bridge_driver = {
	.driver = {
		.name = "ci_bridge_spi",
		.of_match_table = cibridge_match_table,
		.owner = THIS_MODULE,
	},
	.probe = ci_bridge_spi_probe,
@@ -378,7 +422,6 @@ static int __init ci_bridge_init(void)
		goto class_destroy;
	}


	ci.bridge_dev = device_create(ci.bridge_class, NULL, ci.cdev.dev,
				     &ci, "ci_bridge_spi0");
	if (IS_ERR(ci.bridge_dev)) {
+2 −2
Original line number Diff line number Diff line
@@ -4,8 +4,8 @@
#include <uapi/linux/ci-bridge-spi.h>

struct ci_bridge_platform_data {
	unsigned int reset_pin;
	unsigned int interrupt_pin;
	int reset_pin;
	int interrupt_pin;
};

#endif