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

Commit bef358c4 authored by David Wu's avatar David Wu Committed by Wolfram Sang
Browse files

i2c: rk3x: Change SoC data to not use array



Specifying the i2c SoC data in an array provides very little benefit and
gets unwieldly / confusing as the array grows since the next bit of code
needs to refer to elements in the array by their raw integral index.

Let's just create a single 'static const' structure for each SoC so that
we can refer to these structures by ID.

Signed-off-by: default avatarDavid Wu <david.wu@rock-chips.com>
Reviewed-by: default avatarHeiko Stuebner <heiko@sntech.de>
Suggested-by: default avatarDouglas Anderson <dianders@chromium.org>
Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Tested-by: default avatarHeiko Stuebner <heiko@sntech.de>
Signed-off-by: default avatarWolfram Sang <wsa@the-dreams.de>
parent 69eda367
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
@@ -864,17 +864,39 @@ static const struct i2c_algorithm rk3x_i2c_algorithm = {
	.functionality		= rk3x_i2c_func,
};

static struct rk3x_i2c_soc_data soc_data[3] = {
	{ .grf_offset = 0x154 }, /* rk3066 */
	{ .grf_offset = 0x0a4 }, /* rk3188 */
	{ .grf_offset = -1 },    /* no I2C switching needed */
static const struct rk3x_i2c_soc_data rk3066_soc_data = {
	.grf_offset = 0x154,
};

static const struct rk3x_i2c_soc_data rk3188_soc_data = {
	.grf_offset = 0x0a4,
};

static const struct rk3x_i2c_soc_data rk3228_soc_data = {
	.grf_offset = -1,
};

static const struct rk3x_i2c_soc_data rk3288_soc_data = {
	.grf_offset = -1,
};

static const struct of_device_id rk3x_i2c_match[] = {
	{ .compatible = "rockchip,rk3066-i2c", .data = (void *)&soc_data[0] },
	{ .compatible = "rockchip,rk3188-i2c", .data = (void *)&soc_data[1] },
	{ .compatible = "rockchip,rk3228-i2c", .data = (void *)&soc_data[2] },
	{ .compatible = "rockchip,rk3288-i2c", .data = (void *)&soc_data[2] },
	{
		.compatible = "rockchip,rk3066-i2c",
		.data = (void *)&rk3066_soc_data
	},
	{
		.compatible = "rockchip,rk3188-i2c",
		.data = (void *)&rk3188_soc_data
	},
	{
		.compatible = "rockchip,rk3228-i2c",
		.data = (void *)&rk3228_soc_data
	},
	{
		.compatible = "rockchip,rk3288-i2c",
		.data = (void *)&rk3288_soc_data
	},
	{},
};
MODULE_DEVICE_TABLE(of, rk3x_i2c_match);