diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2013-08-19 08:07:54 -0400 |
---|---|---|
committer | Wolfram Sang <wsa@the-dreams.de> | 2013-08-28 05:11:17 -0400 |
commit | 57cd1e3029e5fb4d238ad11fd0d7ad917179fdf2 (patch) | |
tree | 83b26689fc5579def37e039679abcf13d806d0c9 /drivers/i2c/busses/i2c-designware-platdrv.c | |
parent | defc0b2fb5221bca847a9adb8159b88bc3c93904 (diff) |
i2c: designware: get SDA hold time, HCNT and LCNT configuration from ACPI
Some Intel LPSS I2C devices make the SDA hold time and *CNT parameters
available via SSCN (standard mode) and FMCN (fast mode) ACPI methods.
Implement support for this so that we check whether an ACPI method exists
and if it does, fill in the SDA hold time and *CNT values to the device
private structure for core to use.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
Diffstat (limited to 'drivers/i2c/busses/i2c-designware-platdrv.c')
-rw-r--r-- | drivers/i2c/busses/i2c-designware-platdrv.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/i2c/busses/i2c-designware-platdrv.c b/drivers/i2c/busses/i2c-designware-platdrv.c index 6e99d9f56dee..4c1b60539a25 100644 --- a/drivers/i2c/busses/i2c-designware-platdrv.c +++ b/drivers/i2c/busses/i2c-designware-platdrv.c | |||
@@ -53,9 +53,33 @@ static u32 i2c_dw_get_clk_rate_khz(struct dw_i2c_dev *dev) | |||
53 | } | 53 | } |
54 | 54 | ||
55 | #ifdef CONFIG_ACPI | 55 | #ifdef CONFIG_ACPI |
56 | static void dw_i2c_acpi_params(struct platform_device *pdev, char method[], | ||
57 | u16 *hcnt, u16 *lcnt, u32 *sda_hold) | ||
58 | { | ||
59 | struct acpi_buffer buf = { ACPI_ALLOCATE_BUFFER }; | ||
60 | acpi_handle handle = ACPI_HANDLE(&pdev->dev); | ||
61 | union acpi_object *obj; | ||
62 | |||
63 | if (ACPI_FAILURE(acpi_evaluate_object(handle, method, NULL, &buf))) | ||
64 | return; | ||
65 | |||
66 | obj = (union acpi_object *)buf.pointer; | ||
67 | if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 3) { | ||
68 | const union acpi_object *objs = obj->package.elements; | ||
69 | |||
70 | *hcnt = (u16)objs[0].integer.value; | ||
71 | *lcnt = (u16)objs[1].integer.value; | ||
72 | if (sda_hold) | ||
73 | *sda_hold = (u32)objs[2].integer.value; | ||
74 | } | ||
75 | |||
76 | kfree(buf.pointer); | ||
77 | } | ||
78 | |||
56 | static int dw_i2c_acpi_configure(struct platform_device *pdev) | 79 | static int dw_i2c_acpi_configure(struct platform_device *pdev) |
57 | { | 80 | { |
58 | struct dw_i2c_dev *dev = platform_get_drvdata(pdev); | 81 | struct dw_i2c_dev *dev = platform_get_drvdata(pdev); |
82 | bool fs_mode = dev->master_cfg & DW_IC_CON_SPEED_FAST; | ||
59 | 83 | ||
60 | if (!ACPI_HANDLE(&pdev->dev)) | 84 | if (!ACPI_HANDLE(&pdev->dev)) |
61 | return -ENODEV; | 85 | return -ENODEV; |
@@ -63,6 +87,16 @@ static int dw_i2c_acpi_configure(struct platform_device *pdev) | |||
63 | dev->adapter.nr = -1; | 87 | dev->adapter.nr = -1; |
64 | dev->tx_fifo_depth = 32; | 88 | dev->tx_fifo_depth = 32; |
65 | dev->rx_fifo_depth = 32; | 89 | dev->rx_fifo_depth = 32; |
90 | |||
91 | /* | ||
92 | * Try to get SDA hold time and *CNT values from an ACPI method if | ||
93 | * it exists for both supported speed modes. | ||
94 | */ | ||
95 | dw_i2c_acpi_params(pdev, "SSCN", &dev->ss_hcnt, &dev->ss_lcnt, | ||
96 | fs_mode ? NULL : &dev->sda_hold_time); | ||
97 | dw_i2c_acpi_params(pdev, "FMCN", &dev->fs_hcnt, &dev->fs_lcnt, | ||
98 | fs_mode ? &dev->sda_hold_time : NULL); | ||
99 | |||
66 | return 0; | 100 | return 0; |
67 | } | 101 | } |
68 | 102 | ||