Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 363127
b: refs/heads/master
c: 97f00f7
h: refs/heads/master
i:
  363125: cc570eb
  363123: 03a7025
  363119: 14504bf
v: v3
  • Loading branch information
David Brown authored and Greg Kroah-Hartman committed Mar 25, 2013
1 parent 225b830 commit 3f29f85
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 50 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 4a6692e2ac4c6b09235a9568468dd83a380c271d
refs/heads/master: 97f00f7120fe3396302693cdc4b1d11bbacad963
18 changes: 18 additions & 0 deletions trunk/Documentation/devicetree/bindings/arm/msm/ssbi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
* Qualcomm SSBI

Some Qualcomm MSM devices contain a point-to-point serial bus used to
communicate with a limited range of devices (mostly power management
chips).

These require the following properties:

- compatible: "qcom,ssbi"

- qcom,controller-type
indicates the SSBI bus variant the controller should use to talk
with the slave device. This should be one of "ssbi", "ssbi2", or
"pmic-arbiter". The type chosen is determined by the attached
slave.

The slave device should be the single child node of the ssbi device
with a compatible field.
6 changes: 6 additions & 0 deletions trunk/arch/arm/boot/dts/msm8660-surf.dts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@
<0x19c00000 0x1000>;
interrupts = <0 195 0x0>;
};

qcom,ssbi@500000 {
compatible = "qcom,ssbi";
reg = <0x500000 0x1000>;
qcom,controller-type = "pmic-arbiter";
};
};
6 changes: 6 additions & 0 deletions trunk/arch/arm/boot/dts/msm8960-cdp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,10 @@
<0x16400000 0x1000>;
interrupts = <0 154 0x0>;
};

qcom,ssbi@500000 {
compatible = "qcom,ssbi";
reg = <0x500000 0x1000>;
qcom,controller-type = "pmic-arbiter";
};
};
81 changes: 32 additions & 49 deletions trunk/drivers/ssbi/ssbi.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include <linux/slab.h>
#include <linux/msm_ssbi.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>

/* SSBI 2.0 controller registers */
#define SSBI2_CMD 0x0008
Expand Down Expand Up @@ -261,56 +263,13 @@ int msm_ssbi_write(struct device *dev, u16 addr, u8 *buf, int len)
}
EXPORT_SYMBOL_GPL(msm_ssbi_write);

static int msm_ssbi_add_slave(struct msm_ssbi *ssbi,
const struct msm_ssbi_slave_info *slave)
{
struct platform_device *slave_pdev;
int ret;

if (ssbi->slave) {
pr_err("slave already attached??\n");
return -EBUSY;
}

slave_pdev = platform_device_alloc(slave->name, -1);
if (!slave_pdev) {
pr_err("cannot allocate pdev for slave '%s'", slave->name);
ret = -ENOMEM;
goto err;
}

slave_pdev->dev.parent = ssbi->dev;
slave_pdev->dev.platform_data = slave->platform_data;

ret = platform_device_add(slave_pdev);
if (ret) {
pr_err("cannot add slave platform device for '%s'\n",
slave->name);
goto err;
}

ssbi->slave = &slave_pdev->dev;
return 0;

err:
if (slave_pdev)
platform_device_put(slave_pdev);
return ret;
}

static int msm_ssbi_probe(struct platform_device *pdev)
{
const struct msm_ssbi_platform_data *pdata = pdev->dev.platform_data;
struct device_node *np = pdev->dev.of_node;
struct resource *mem_res;
struct msm_ssbi *ssbi;
int ret = 0;

if (!pdata) {
pr_err("missing platform data\n");
return -EINVAL;
}

pr_debug("%s\n", pdata->slave.name);
const char *type;

ssbi = kzalloc(sizeof(struct msm_ssbi), GFP_KERNEL);
if (!ssbi) {
Expand All @@ -334,7 +293,25 @@ static int msm_ssbi_probe(struct platform_device *pdev)
ssbi->dev = &pdev->dev;
platform_set_drvdata(pdev, ssbi);

ssbi->controller_type = pdata->controller_type;
type = of_get_property(np, "qcom,controller-type", NULL);
if (type == NULL) {
pr_err("Missing qcom,controller-type property\n");
ret = -EINVAL;
goto err_ssbi_controller;
}
dev_info(&pdev->dev, "SSBI controller type: '%s'\n", type);
if (strcmp(type, "ssbi") == 0)
ssbi->controller_type = MSM_SBI_CTRL_SSBI;
else if (strcmp(type, "ssbi2") == 0)
ssbi->controller_type = MSM_SBI_CTRL_SSBI2;
else if (strcmp(type, "pmic-arbiter") == 0)
ssbi->controller_type = MSM_SBI_CTRL_PMIC_ARBITER;
else {
pr_err("Unknown qcom,controller-type\n");
ret = -EINVAL;
goto err_ssbi_controller;
}

if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) {
ssbi->read = msm_ssbi_pa_read_bytes;
ssbi->write = msm_ssbi_pa_write_bytes;
Expand All @@ -345,13 +322,13 @@ static int msm_ssbi_probe(struct platform_device *pdev)

spin_lock_init(&ssbi->lock);

ret = msm_ssbi_add_slave(ssbi, &pdata->slave);
ret = of_platform_populate(np, NULL, NULL, &pdev->dev);
if (ret)
goto err_ssbi_add_slave;
goto err_ssbi_controller;

return 0;

err_ssbi_add_slave:
err_ssbi_controller:
platform_set_drvdata(pdev, NULL);
iounmap(ssbi->base);
err_ioremap:
Expand All @@ -370,12 +347,18 @@ static int msm_ssbi_remove(struct platform_device *pdev)
return 0;
}

static struct of_device_id ssbi_match_table[] = {
{ .compatible = "qcom,ssbi" },
{}
};

static struct platform_driver msm_ssbi_driver = {
.probe = msm_ssbi_probe,
.remove = msm_ssbi_remove,
.driver = {
.name = "msm_ssbi",
.owner = THIS_MODULE,
.of_match_table = ssbi_match_table,
},
};

Expand Down

0 comments on commit 3f29f85

Please sign in to comment.