aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/radeon/radeon_i2c.c
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2010-08-05 21:21:16 -0400
committerDave Airlie <airlied@redhat.com>2010-08-09 20:46:48 -0400
commitf376b94fbc0a313a606748206340cbef6c2adf6b (patch)
tree79687e8c214bf70251c242f8042bc46d6fc61020 /drivers/gpu/drm/radeon/radeon_i2c.c
parent1729dd33d20bddf1b3f371f3090f0cfd6be50b7a (diff)
drm/radeon/kms: unify i2c handling
Previously we added i2c buses as needed when enumerating connectors power management, etc. This only exposed the actual buses used and could have lead to the same buse getting created more than once if one buses was used for more than one purpose. This patch sets up all i2c buses on the card in one place and users of the buses just point back to the one instance. Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu/drm/radeon/radeon_i2c.c')
-rw-r--r--drivers/gpu/drm/radeon/radeon_i2c.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c b/drivers/gpu/drm/radeon/radeon_i2c.c
index 5def6f5dff38..e71f2eb02ee2 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -960,6 +960,59 @@ void radeon_i2c_destroy(struct radeon_i2c_chan *i2c)
960 kfree(i2c); 960 kfree(i2c);
961} 961}
962 962
963/* Add the default buses */
964void radeon_i2c_init(struct radeon_device *rdev)
965{
966 if (rdev->is_atom_bios)
967 radeon_atombios_i2c_init(rdev);
968 else
969 radeon_combios_i2c_init(rdev);
970}
971
972/* remove all the buses */
973void radeon_i2c_fini(struct radeon_device *rdev)
974{
975 int i;
976
977 for (i = 0; i < RADEON_MAX_I2C_BUS; i++) {
978 if (rdev->i2c_bus[i]) {
979 radeon_i2c_destroy(rdev->i2c_bus[i]);
980 rdev->i2c_bus[i] = NULL;
981 }
982 }
983}
984
985/* Add additional buses */
986void radeon_i2c_add(struct radeon_device *rdev,
987 struct radeon_i2c_bus_rec *rec,
988 const char *name)
989{
990 struct drm_device *dev = rdev->ddev;
991 int i;
992
993 for (i = 0; i < RADEON_MAX_I2C_BUS; i++) {
994 if (!rdev->i2c_bus[i]) {
995 rdev->i2c_bus[i] = radeon_i2c_create(dev, rec, name);
996 return;
997 }
998 }
999}
1000
1001/* looks up bus based on id */
1002struct radeon_i2c_chan *radeon_i2c_lookup(struct radeon_device *rdev,
1003 struct radeon_i2c_bus_rec *i2c_bus)
1004{
1005 int i;
1006
1007 for (i = 0; i < RADEON_MAX_I2C_BUS; i++) {
1008 if (rdev->i2c_bus[i] &&
1009 (rdev->i2c_bus[i]->rec.i2c_id == i2c_bus->i2c_id)) {
1010 return rdev->i2c_bus[i];
1011 }
1012 }
1013 return NULL;
1014}
1015
963struct drm_encoder *radeon_best_encoder(struct drm_connector *connector) 1016struct drm_encoder *radeon_best_encoder(struct drm_connector *connector)
964{ 1017{
965 return NULL; 1018 return NULL;