mirror of
https://gitlab.freedesktop.org/mesa/drm.git
synced 2025-12-20 21:00:12 +01:00
Fix up the radeon i2c error handing
This commit is contained in:
parent
17ce33835a
commit
d76f734f68
2 changed files with 39 additions and 49 deletions
|
|
@ -82,10 +82,11 @@ static int gpio_getsda(void* data)
|
||||||
return (val & VGA_DDC_DATA_INPUT) ? 1 : 0;
|
return (val & VGA_DDC_DATA_INPUT) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
|
static int setup_i2c_bus(drm_device_t * dev, struct radeon_i2c_chan *chan, const char *name)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
chan->dev = dev;
|
||||||
strcpy(chan->adapter.name, name);
|
strcpy(chan->adapter.name, name);
|
||||||
chan->adapter.owner = THIS_MODULE;
|
chan->adapter.owner = THIS_MODULE;
|
||||||
chan->adapter.id = I2C_ALGO_ATI;
|
chan->adapter.id = I2C_ALGO_ATI;
|
||||||
|
|
@ -106,39 +107,33 @@ static int setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
|
||||||
gpio_setscl(chan, 1);
|
gpio_setscl(chan, 1);
|
||||||
udelay(20);
|
udelay(20);
|
||||||
|
|
||||||
rc = i2c_bit_add_bus(&chan->adapter);
|
if ((rc = i2c_bit_add_bus(&chan->adapter))) {
|
||||||
if (rc == 0)
|
i2c_set_adapdata(&chan->adapter, NULL);
|
||||||
DRM_DEBUG("I2C bus %s registered.\n", name);
|
chan->dev = NULL;
|
||||||
else
|
|
||||||
DRM_ERROR("Failed to register I2C bus %s.\n", name);
|
DRM_ERROR("Failed to register I2C bus %s.\n", name);
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
|
DRM_DEBUG("I2C bus %s registered.\n", name);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_create_i2c_busses(drm_device_t * dev)
|
int radeon_create_i2c_busses(drm_device_t * dev)
|
||||||
{
|
{
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
|
|
||||||
dev_priv->i2c[0].dev = dev;
|
|
||||||
dev_priv->i2c[0].ddc_reg = GPIO_MONID;
|
dev_priv->i2c[0].ddc_reg = GPIO_MONID;
|
||||||
/* Don't return the error from setup. It is not fatal */
|
/* Don't return the error from setup. It is not fatal */
|
||||||
/* if the bus can not be initialized */
|
/* if the bus can not be initialized */
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[0], "monid"))
|
setup_i2c_bus(dev, &dev_priv->i2c[0], "monid");
|
||||||
dev_priv->i2c[0].dev = NULL;
|
|
||||||
|
|
||||||
dev_priv->i2c[1].dev = dev;
|
|
||||||
dev_priv->i2c[1].ddc_reg = GPIO_DVI_DDC;
|
dev_priv->i2c[1].ddc_reg = GPIO_DVI_DDC;
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[1], "dvi"))
|
setup_i2c_bus(dev, &dev_priv->i2c[1], "dvi");
|
||||||
dev_priv->i2c[1].dev = NULL;
|
|
||||||
|
|
||||||
dev_priv->i2c[2].dev = dev;
|
|
||||||
dev_priv->i2c[2].ddc_reg = GPIO_VGA_DDC;
|
dev_priv->i2c[2].ddc_reg = GPIO_VGA_DDC;
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[2], "vga"))
|
setup_i2c_bus(dev, &dev_priv->i2c[2], "vga");
|
||||||
dev_priv->i2c[2].dev = NULL;
|
|
||||||
|
|
||||||
dev_priv->i2c[3].dev = dev;
|
|
||||||
dev_priv->i2c[3].ddc_reg = GPIO_CRT2_DDC;
|
dev_priv->i2c[3].ddc_reg = GPIO_CRT2_DDC;
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[3], "crt2"))
|
setup_i2c_bus(dev, &dev_priv->i2c[3], "crt2");
|
||||||
dev_priv->i2c[0].dev = NULL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -151,8 +146,8 @@ void radeon_delete_i2c_busses(drm_device_t *dev)
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (dev_priv->i2c[i].dev) {
|
if (dev_priv->i2c[i].dev) {
|
||||||
ret = i2c_bit_del_bus(&dev_priv->i2c[i].adapter);
|
ret = i2c_bit_del_bus(&dev_priv->i2c[i].adapter);
|
||||||
|
dev_priv->i2c[i].dev = NULL;
|
||||||
}
|
}
|
||||||
dev_priv->i2c[i].dev = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -81,22 +81,23 @@ static int gpio_getsda(void *data)
|
||||||
return (val & VGA_DDC_DATA_INPUT) ? 1 : 0;
|
return (val & VGA_DDC_DATA_INPUT) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
|
static int setup_i2c_bus(drm_device_t * dev, struct radeon_i2c_chan *chan, const char *name)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
|
chan->dev = dev;
|
||||||
strcpy(chan->adapter.name, name);
|
strcpy(chan->adapter.name, name);
|
||||||
chan->adapter.owner = THIS_MODULE;
|
chan->adapter.owner = THIS_MODULE;
|
||||||
chan->adapter.id = I2C_ALGO_ATI;
|
chan->adapter.id = I2C_ALGO_ATI;
|
||||||
chan->adapter.algo_data = &chan->algo;
|
chan->adapter.algo_data = &chan->algo;
|
||||||
chan->adapter.dev.parent = &chan->dev->pdev->dev;
|
chan->adapter.dev.parent = &chan->dev->pdev->dev;
|
||||||
chan->algo.setsda = gpio_setsda;
|
chan->algo.setsda = gpio_setsda;
|
||||||
chan->algo.setscl = gpio_setscl;
|
chan->algo.setscl = gpio_setscl;
|
||||||
chan->algo.getsda = gpio_getsda;
|
chan->algo.getsda = gpio_getsda;
|
||||||
chan->algo.getscl = gpio_getscl;
|
chan->algo.getscl = gpio_getscl;
|
||||||
chan->algo.udelay = 40;
|
chan->algo.udelay = 40;
|
||||||
chan->algo.timeout = 20;
|
chan->algo.timeout = 20;
|
||||||
chan->algo.data = chan;
|
chan->algo.data = chan;
|
||||||
|
|
||||||
i2c_set_adapdata(&chan->adapter, chan);
|
i2c_set_adapdata(&chan->adapter, chan);
|
||||||
|
|
||||||
|
|
@ -105,39 +106,33 @@ static int setup_i2c_bus(struct radeon_i2c_chan *chan, const char *name)
|
||||||
gpio_setscl(chan, 1);
|
gpio_setscl(chan, 1);
|
||||||
udelay(20);
|
udelay(20);
|
||||||
|
|
||||||
rc = i2c_bit_add_bus(&chan->adapter);
|
if ((rc = i2c_bit_add_bus(&chan->adapter))) {
|
||||||
if (rc == 0)
|
i2c_set_adapdata(&chan->adapter, NULL);
|
||||||
DRM_DEBUG("I2C bus %s registered.\n", name);
|
chan->dev = NULL;
|
||||||
else
|
|
||||||
DRM_ERROR("Failed to register I2C bus %s.\n", name);
|
DRM_ERROR("Failed to register I2C bus %s.\n", name);
|
||||||
return rc;
|
return rc;
|
||||||
|
}
|
||||||
|
DRM_DEBUG("I2C bus %s registered.\n", name);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int radeon_create_i2c_busses(drm_device_t * dev)
|
int radeon_create_i2c_busses(drm_device_t * dev)
|
||||||
{
|
{
|
||||||
drm_radeon_private_t *dev_priv = dev->dev_private;
|
drm_radeon_private_t *dev_priv = dev->dev_private;
|
||||||
|
|
||||||
dev_priv->i2c[0].dev = dev;
|
|
||||||
dev_priv->i2c[0].ddc_reg = GPIO_MONID;
|
dev_priv->i2c[0].ddc_reg = GPIO_MONID;
|
||||||
/* Don't return the error from setup. It is not fatal */
|
/* Don't return the error from setup. It is not fatal */
|
||||||
/* if the bus can not be initialized */
|
/* if the bus can not be initialized */
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[0], "monid"))
|
setup_i2c_bus(dev, &dev_priv->i2c[0], "monid");
|
||||||
dev_priv->i2c[0].dev = NULL;
|
|
||||||
|
|
||||||
dev_priv->i2c[1].dev = dev;
|
|
||||||
dev_priv->i2c[1].ddc_reg = GPIO_DVI_DDC;
|
dev_priv->i2c[1].ddc_reg = GPIO_DVI_DDC;
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[1], "dvi"))
|
setup_i2c_bus(dev, &dev_priv->i2c[1], "dvi");
|
||||||
dev_priv->i2c[1].dev = NULL;
|
|
||||||
|
|
||||||
dev_priv->i2c[2].dev = dev;
|
|
||||||
dev_priv->i2c[2].ddc_reg = GPIO_VGA_DDC;
|
dev_priv->i2c[2].ddc_reg = GPIO_VGA_DDC;
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[2], "vga"))
|
setup_i2c_bus(dev, &dev_priv->i2c[2], "vga");
|
||||||
dev_priv->i2c[2].dev = NULL;
|
|
||||||
|
|
||||||
dev_priv->i2c[3].dev = dev;
|
|
||||||
dev_priv->i2c[3].ddc_reg = GPIO_CRT2_DDC;
|
dev_priv->i2c[3].ddc_reg = GPIO_CRT2_DDC;
|
||||||
if (!setup_i2c_bus(&dev_priv->i2c[3], "crt2"))
|
setup_i2c_bus(dev, &dev_priv->i2c[3], "crt2");
|
||||||
dev_priv->i2c[0].dev = NULL;
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -150,8 +145,8 @@ void radeon_delete_i2c_busses(drm_device_t * dev)
|
||||||
for (i = 0; i < 4; i++) {
|
for (i = 0; i < 4; i++) {
|
||||||
if (dev_priv->i2c[i].dev) {
|
if (dev_priv->i2c[i].dev) {
|
||||||
ret = i2c_bit_del_bus(&dev_priv->i2c[i].adapter);
|
ret = i2c_bit_del_bus(&dev_priv->i2c[i].adapter);
|
||||||
|
dev_priv->i2c[i].dev = NULL;
|
||||||
}
|
}
|
||||||
dev_priv->i2c[i].dev = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue