linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: sii902x: initialize CEC device
@ 2019-03-29 12:35 Yannick Fertré
  2019-03-30  8:12 ` kbuild test robot
  2019-03-30  8:12 ` [RFC PATCH] drm/bridge: sii902x: sii902x_cec_init() can be static kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Yannick Fertré @ 2019-03-29 12:35 UTC (permalink / raw)
  To: Andrzej Hajda, Laurent Pinchart, David Airlie, Daniel Vetter,
	dri-devel, linux-kernel, linux-stm32
  Cc: Benjamin Gaignard, Yannick Fertre, Philippe Cornu, Alexandre Torgue

Initialize the CEC device embedded into sii902x bridge. By default,
the CEC device must be disabled to allow other CEC devices to bypass
the bridge.

Signed-off-by: Yannick Fertré <yannick.fertre@st.com>
---
 drivers/gpu/drm/bridge/sii902x.c | 64 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 64 insertions(+)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index 08e12fe..d33c097 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -83,9 +83,15 @@
 
 #define SII902X_I2C_BUS_ACQUISITION_TIMEOUT_MS	500
 
+#define SII902X_CEC_I2C_ADDR_DEFAULT		0x60
+#define SII902X_CEC_SETUP			0x8e
+#define CEC_EN					BIT(4)
+
 struct sii902x {
 	struct i2c_client *i2c;
+	struct i2c_client *i2c_cec;
 	struct regmap *regmap;
+	struct regmap *regmap_cec;
 	struct drm_bridge bridge;
 	struct drm_connector connector;
 	struct gpio_desc *reset_gpio;
@@ -331,6 +337,22 @@ static const struct regmap_config sii902x_regmap_config = {
 	.cache_type = REGCACHE_NONE,
 };
 
+static const struct regmap_range sii902x_cec_volatile_ranges[] = {
+	{ .range_min = 0x84, .range_max = 0xe4 },
+};
+
+static const struct regmap_access_table sii902x_cec_volatile_table = {
+	.yes_ranges = sii902x_cec_volatile_ranges,
+	.n_yes_ranges = ARRAY_SIZE(sii902x_cec_volatile_ranges),
+};
+
+static const struct regmap_config sii902x_cec_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.volatile_table = &sii902x_cec_volatile_table,
+	.cache_type = REGCACHE_NONE,
+};
+
 static irqreturn_t sii902x_interrupt(int irq, void *data)
 {
 	struct sii902x *sii902x = data;
@@ -460,6 +482,39 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core *mux, u32 chan_id)
 	return 0;
 }
 
+int sii902x_cec_init(struct device *dev, struct sii902x *sii902x)
+{
+	struct i2c_client *client;
+	int ret;
+
+	client = i2c_new_secondary_device(sii902x->i2c, "cec",
+					  SII902X_CEC_I2C_ADDR_DEFAULT);
+	if (!client)
+		return -EINVAL;
+
+	sii902x->i2c_cec = client;
+
+	i2c_set_clientdata(sii902x->i2c_cec, sii902x);
+
+	sii902x->regmap_cec = devm_regmap_init_i2c(sii902x->i2c_cec,
+						   &sii902x_cec_regmap_config);
+	if (IS_ERR(sii902x->regmap_cec)) {
+		ret = PTR_ERR(sii902x->regmap_cec);
+		goto err;
+	}
+
+	/*
+	 * By default, CEC must be disabled to allow other CEC devives
+	 * to bypass the bridge.
+	 */
+	regmap_update_bits(sii902x->regmap_cec, SII902X_CEC_SETUP, CEC_EN, 0);
+
+	return 0;
+err:
+	i2c_unregister_device(sii902x->i2c_cec);
+	return ret;
+}
+
 static int sii902x_probe(struct i2c_client *client,
 			 const struct i2c_device_id *id)
 {
@@ -542,7 +597,16 @@ static int sii902x_probe(struct i2c_client *client,
 		return -ENOMEM;
 
 	sii902x->i2cmux->priv = sii902x;
+
+	ret = sii902x_cec_init(dev, sii902x);
+	if (ret)
+		goto err;
+
 	return i2c_mux_add_adapter(sii902x->i2cmux, 0, 0, 0);
+err:
+	drm_bridge_remove(&sii902x->bridge);
+
+	return ret;
 }
 
 static int sii902x_remove(struct i2c_client *client)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] drm/bridge: sii902x: initialize CEC device
  2019-03-29 12:35 [PATCH] drm/bridge: sii902x: initialize CEC device Yannick Fertré
@ 2019-03-30  8:12 ` kbuild test robot
  2019-03-30  8:12 ` [RFC PATCH] drm/bridge: sii902x: sii902x_cec_init() can be static kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2019-03-30  8:12 UTC (permalink / raw)
  To: Yannick Fertré
  Cc: kbuild-all, Andrzej Hajda, Laurent Pinchart, David Airlie,
	Daniel Vetter, dri-devel, linux-kernel, linux-stm32,
	Yannick Fertre, Alexandre Torgue, Benjamin Gaignard,
	Philippe Cornu

Hi "Yannick,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.1-rc2 next-20190329]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Yannick-Fertr/drm-bridge-sii902x-initialize-CEC-device/20190330-102132
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'


sparse warnings: (new ones prefixed by >>)

>> drivers/gpu/drm/bridge/sii902x.c:485:5: sparse: symbol 'sii902x_cec_init' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC PATCH] drm/bridge: sii902x: sii902x_cec_init() can be static
  2019-03-29 12:35 [PATCH] drm/bridge: sii902x: initialize CEC device Yannick Fertré
  2019-03-30  8:12 ` kbuild test robot
@ 2019-03-30  8:12 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2019-03-30  8:12 UTC (permalink / raw)
  To: Yannick Fertré
  Cc: kbuild-all, Andrzej Hajda, Laurent Pinchart, David Airlie,
	Daniel Vetter, dri-devel, linux-kernel, linux-stm32,
	Yannick Fertre, Alexandre Torgue, Benjamin Gaignard,
	Philippe Cornu


Fixes: 1402bda01406 ("drm/bridge: sii902x: initialize CEC device")
Signed-off-by: kbuild test robot <lkp@intel.com>
---
 sii902x.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/sii902x.c b/drivers/gpu/drm/bridge/sii902x.c
index d33c097..42a0a7a 100644
--- a/drivers/gpu/drm/bridge/sii902x.c
+++ b/drivers/gpu/drm/bridge/sii902x.c
@@ -482,7 +482,7 @@ static int sii902x_i2c_bypass_deselect(struct i2c_mux_core *mux, u32 chan_id)
 	return 0;
 }
 
-int sii902x_cec_init(struct device *dev, struct sii902x *sii902x)
+static int sii902x_cec_init(struct device *dev, struct sii902x *sii902x)
 {
 	struct i2c_client *client;
 	int ret;

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-30  8:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-29 12:35 [PATCH] drm/bridge: sii902x: initialize CEC device Yannick Fertré
2019-03-30  8:12 ` kbuild test robot
2019-03-30  8:12 ` [RFC PATCH] drm/bridge: sii902x: sii902x_cec_init() can be static kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).