Skip to content

Commit b04ce63

Browse files
Bartosz GolaszewskiAndi Shyti
authored andcommitted
i2c: davinci: kill platform data
There are no more board file users of this driver. The platform data structure is only used internally. Two of the four fields it stores are not used at all anymore. Pull the remainder into the driver data struct and shrink code by removing parts that are now dead code. Signed-off-by: Bartosz Golaszewski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Andi Shyti <[email protected]>
1 parent 70f3d36 commit b04ce63

File tree

2 files changed

+19
-91
lines changed

2 files changed

+19
-91
lines changed

drivers/i2c/busses/i2c-davinci.c

Lines changed: 19 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <linux/cpufreq.h>
2727
#include <linux/gpio/consumer.h>
2828
#include <linux/of.h>
29-
#include <linux/platform_data/i2c-davinci.h>
3029
#include <linux/pm_runtime.h>
3130

3231
/* ----- global defines ----------------------------------------------- */
@@ -117,6 +116,8 @@
117116
/* timeout for pm runtime autosuspend */
118117
#define DAVINCI_I2C_PM_TIMEOUT 1000 /* ms */
119118

119+
#define DAVINCI_I2C_DEFAULT_BUS_FREQ 100
120+
120121
struct davinci_i2c_dev {
121122
struct device *dev;
122123
void __iomem *base;
@@ -132,13 +133,10 @@ struct davinci_i2c_dev {
132133
#ifdef CONFIG_CPU_FREQ
133134
struct notifier_block freq_transition;
134135
#endif
135-
struct davinci_i2c_platform_data *pdata;
136-
};
137-
138-
/* default platform data to use if not supplied in the platform_device */
139-
static struct davinci_i2c_platform_data davinci_i2c_platform_data_default = {
140-
.bus_freq = 100,
141-
.bus_delay = 0,
136+
/* standard bus frequency (kHz) */
137+
unsigned int bus_freq;
138+
/* Chip has a ICPFUNC register */
139+
bool has_pfunc;
142140
};
143141

144142
static inline void davinci_i2c_write_reg(struct davinci_i2c_dev *i2c_dev,
@@ -168,7 +166,6 @@ static inline void davinci_i2c_reset_ctrl(struct davinci_i2c_dev *i2c_dev,
168166

169167
static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
170168
{
171-
struct davinci_i2c_platform_data *pdata = dev->pdata;
172169
u16 psc;
173170
u32 clk;
174171
u32 d;
@@ -212,16 +209,16 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
212209
if (of_node && of_device_is_compatible(of_node, "ti,keystone-i2c"))
213210
d = 6;
214211

215-
clk = ((input_clock / (psc + 1)) / (pdata->bus_freq * 1000));
212+
clk = ((input_clock / (psc + 1)) / (dev->bus_freq * 1000));
216213
/* Avoid driving the bus too fast because of rounding errors above */
217-
if (input_clock / (psc + 1) / clk > pdata->bus_freq * 1000)
214+
if (input_clock / (psc + 1) / clk > dev->bus_freq * 1000)
218215
clk++;
219216
/*
220217
* According to I2C-BUS Spec 2.1, in FAST-MODE LOW period should be at
221218
* least 1.3uS, which is not the case with 50% duty cycle. Driving HIGH
222219
* to LOW ratio as 1 to 2 is more safe.
223220
*/
224-
if (pdata->bus_freq > 100)
221+
if (dev->bus_freq > 100)
225222
clkl = (clk << 1) / 3;
226223
else
227224
clkl = (clk >> 1);
@@ -255,8 +252,6 @@ static void i2c_davinci_calc_clk_dividers(struct davinci_i2c_dev *dev)
255252
*/
256253
static int i2c_davinci_init(struct davinci_i2c_dev *dev)
257254
{
258-
struct davinci_i2c_platform_data *pdata = dev->pdata;
259-
260255
/* put I2C into reset */
261256
davinci_i2c_reset_ctrl(dev, 0);
262257

@@ -274,8 +269,7 @@ static int i2c_davinci_init(struct davinci_i2c_dev *dev)
274269
davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKL_REG));
275270
dev_dbg(dev->dev, "CLKH = %d\n",
276271
davinci_i2c_read_reg(dev, DAVINCI_I2C_CLKH_REG));
277-
dev_dbg(dev->dev, "bus_freq = %dkHz, bus_delay = %d\n",
278-
pdata->bus_freq, pdata->bus_delay);
272+
dev_dbg(dev->dev, "bus_freq = %dkHz\n", dev->bus_freq);
279273

280274

281275
/* Take the I2C module out of reset: */
@@ -309,12 +303,6 @@ static void davinci_i2c_unprepare_recovery(struct i2c_adapter *adap)
309303
i2c_davinci_init(dev);
310304
}
311305

312-
static struct i2c_bus_recovery_info davinci_i2c_gpio_recovery_info = {
313-
.recover_bus = i2c_generic_scl_recovery,
314-
.prepare_recovery = davinci_i2c_prepare_recovery,
315-
.unprepare_recovery = davinci_i2c_unprepare_recovery,
316-
};
317-
318306
static void davinci_i2c_set_scl(struct i2c_adapter *adap, int val)
319307
{
320308
struct davinci_i2c_dev *dev = i2c_get_adapdata(adap);
@@ -414,7 +402,6 @@ static int
414402
i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
415403
{
416404
struct davinci_i2c_dev *dev = i2c_get_adapdata(adap);
417-
struct davinci_i2c_platform_data *pdata = dev->pdata;
418405
u32 flag;
419406
u16 w;
420407
unsigned long time_left;
@@ -424,10 +411,6 @@ i2c_davinci_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg, int stop)
424411
return -EADDRNOTAVAIL;
425412
}
426413

427-
/* Introduce a delay, required for some boards (e.g Davinci EVM) */
428-
if (pdata->bus_delay)
429-
udelay(pdata->bus_delay);
430-
431414
/* set the target address */
432415
davinci_i2c_write_reg(dev, DAVINCI_I2C_SAR_REG, msg->addr);
433416

@@ -758,8 +741,8 @@ static int davinci_i2c_probe(struct platform_device *pdev)
758741
{
759742
struct davinci_i2c_dev *dev;
760743
struct i2c_adapter *adap;
761-
struct i2c_bus_recovery_info *rinfo;
762744
int r, irq;
745+
u32 prop;
763746

764747
irq = platform_get_irq(pdev, 0);
765748
if (irq < 0)
@@ -773,29 +756,15 @@ static int davinci_i2c_probe(struct platform_device *pdev)
773756

774757
dev->dev = &pdev->dev;
775758
dev->irq = irq;
776-
dev->pdata = dev_get_platdata(&pdev->dev);
777759
platform_set_drvdata(pdev, dev);
778760

779-
if (!dev->pdata && pdev->dev.of_node) {
780-
u32 prop;
781-
782-
dev->pdata = devm_kzalloc(&pdev->dev,
783-
sizeof(struct davinci_i2c_platform_data), GFP_KERNEL);
784-
if (!dev->pdata)
785-
return -ENOMEM;
786-
787-
memcpy(dev->pdata, &davinci_i2c_platform_data_default,
788-
sizeof(struct davinci_i2c_platform_data));
789-
if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency",
790-
&prop))
791-
dev->pdata->bus_freq = prop / 1000;
792-
793-
dev->pdata->has_pfunc =
794-
of_property_read_bool(pdev->dev.of_node,
795-
"ti,has-pfunc");
796-
} else if (!dev->pdata) {
797-
dev->pdata = &davinci_i2c_platform_data_default;
798-
}
761+
r = device_property_read_u32(&pdev->dev, "clock-frequency", &prop);
762+
if (r)
763+
prop = DAVINCI_I2C_DEFAULT_BUS_FREQ;
764+
765+
dev->bus_freq = prop / 1000;
766+
767+
dev->has_pfunc = device_property_present(&pdev->dev, "ti,has-pfunc");
799768

800769
dev->clk = devm_clk_get(&pdev->dev, NULL);
801770
if (IS_ERR(dev->clk))
@@ -843,23 +812,8 @@ static int davinci_i2c_probe(struct platform_device *pdev)
843812
adap->timeout = DAVINCI_I2C_TIMEOUT;
844813
adap->dev.of_node = pdev->dev.of_node;
845814

846-
if (dev->pdata->has_pfunc)
815+
if (dev->has_pfunc)
847816
adap->bus_recovery_info = &davinci_i2c_scl_recovery_info;
848-
else if (dev->pdata->gpio_recovery) {
849-
rinfo = &davinci_i2c_gpio_recovery_info;
850-
adap->bus_recovery_info = rinfo;
851-
rinfo->scl_gpiod = devm_gpiod_get(&pdev->dev, "scl",
852-
GPIOD_OUT_HIGH_OPEN_DRAIN);
853-
if (IS_ERR(rinfo->scl_gpiod)) {
854-
r = PTR_ERR(rinfo->scl_gpiod);
855-
goto err_unuse_clocks;
856-
}
857-
rinfo->sda_gpiod = devm_gpiod_get(&pdev->dev, "sda", GPIOD_IN);
858-
if (IS_ERR(rinfo->sda_gpiod)) {
859-
r = PTR_ERR(rinfo->sda_gpiod);
860-
goto err_unuse_clocks;
861-
}
862-
}
863817

864818
adap->nr = pdev->id;
865819
r = i2c_add_numbered_adapter(adap);

include/linux/platform_data/i2c-davinci.h

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)