aboutsummaryrefslogtreecommitdiffstats
path: root/sound
diff options
context:
space:
mode:
authorAndreas Schwab <schwab@linux-m68k.org>2012-06-09 09:58:56 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2012-07-11 04:22:48 -0400
commit26b0d14106954ae46d2f4f7eec3481828a210f7d (patch)
tree6cee7e1128f784ab86deefc9ae8332d364d73627 /sound
parent3a3dd0186f619b74e61e6f29dddcaf59af7d3cac (diff)
sound/aoa: Adapt to new i2c probing scheme
The i2c-powermac driver now creates the i2c devices properly from the device-tree, including workarounds for broken or missing device-tree bits, so let's just use the normal probe methods and get rid of the hand made device creation code. Signed-off-by: Andreas Schwab <schwab@linux-m68k.org> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'sound')
-rw-r--r--sound/aoa/codecs/onyx.c75
-rw-r--r--sound/aoa/codecs/tas.c80
2 files changed, 6 insertions, 149 deletions
diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
index 270790d384e2..4cedc6950d72 100644
--- a/sound/aoa/codecs/onyx.c
+++ b/sound/aoa/codecs/onyx.c
@@ -997,45 +997,10 @@ static void onyx_exit_codec(struct aoa_codec *codec)
997 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx); 997 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
998} 998}
999 999
1000static int onyx_create(struct i2c_adapter *adapter,
1001 struct device_node *node,
1002 int addr)
1003{
1004 struct i2c_board_info info;
1005 struct i2c_client *client;
1006
1007 memset(&info, 0, sizeof(struct i2c_board_info));
1008 strlcpy(info.type, "aoa_codec_onyx", I2C_NAME_SIZE);
1009 info.addr = addr;
1010 info.platform_data = node;
1011 client = i2c_new_device(adapter, &info);
1012 if (!client)
1013 return -ENODEV;
1014
1015 /*
1016 * We know the driver is already loaded, so the device should be
1017 * already bound. If not it means binding failed, which suggests
1018 * the device doesn't really exist and should be deleted.
1019 * Ideally this would be replaced by better checks _before_
1020 * instantiating the device.
1021 */
1022 if (!client->driver) {
1023 i2c_unregister_device(client);
1024 return -ENODEV;
1025 }
1026
1027 /*
1028 * Let i2c-core delete that device on driver removal.
1029 * This is safe because i2c-core holds the core_lock mutex for us.
1030 */
1031 list_add_tail(&client->detected, &client->driver->clients);
1032 return 0;
1033}
1034
1035static int onyx_i2c_probe(struct i2c_client *client, 1000static int onyx_i2c_probe(struct i2c_client *client,
1036 const struct i2c_device_id *id) 1001 const struct i2c_device_id *id)
1037{ 1002{
1038 struct device_node *node = client->dev.platform_data; 1003 struct device_node *node = client->dev.of_node;
1039 struct onyx *onyx; 1004 struct onyx *onyx;
1040 u8 dummy; 1005 u8 dummy;
1041 1006
@@ -1071,40 +1036,6 @@ static int onyx_i2c_probe(struct i2c_client *client,
1071 return -ENODEV; 1036 return -ENODEV;
1072} 1037}
1073 1038
1074static int onyx_i2c_attach(struct i2c_adapter *adapter)
1075{
1076 struct device_node *busnode, *dev = NULL;
1077 struct pmac_i2c_bus *bus;
1078
1079 bus = pmac_i2c_adapter_to_bus(adapter);
1080 if (bus == NULL)
1081 return -ENODEV;
1082 busnode = pmac_i2c_get_bus_node(bus);
1083
1084 while ((dev = of_get_next_child(busnode, dev)) != NULL) {
1085 if (of_device_is_compatible(dev, "pcm3052")) {
1086 const u32 *addr;
1087 printk(KERN_DEBUG PFX "found pcm3052\n");
1088 addr = of_get_property(dev, "reg", NULL);
1089 if (!addr)
1090 return -ENODEV;
1091 return onyx_create(adapter, dev, (*addr)>>1);
1092 }
1093 }
1094
1095 /* if that didn't work, try desperate mode for older
1096 * machines that have stuff missing from the device tree */
1097
1098 if (!of_device_is_compatible(busnode, "k2-i2c"))
1099 return -ENODEV;
1100
1101 printk(KERN_DEBUG PFX "found k2-i2c, checking if onyx chip is on it\n");
1102 /* probe both possible addresses for the onyx chip */
1103 if (onyx_create(adapter, NULL, 0x46) == 0)
1104 return 0;
1105 return onyx_create(adapter, NULL, 0x47);
1106}
1107
1108static int onyx_i2c_remove(struct i2c_client *client) 1039static int onyx_i2c_remove(struct i2c_client *client)
1109{ 1040{
1110 struct onyx *onyx = i2c_get_clientdata(client); 1041 struct onyx *onyx = i2c_get_clientdata(client);
@@ -1117,16 +1048,16 @@ static int onyx_i2c_remove(struct i2c_client *client)
1117} 1048}
1118 1049
1119static const struct i2c_device_id onyx_i2c_id[] = { 1050static const struct i2c_device_id onyx_i2c_id[] = {
1120 { "aoa_codec_onyx", 0 }, 1051 { "MAC,pcm3052", 0 },
1121 { } 1052 { }
1122}; 1053};
1054MODULE_DEVICE_TABLE(i2c,onyx_i2c_id);
1123 1055
1124static struct i2c_driver onyx_driver = { 1056static struct i2c_driver onyx_driver = {
1125 .driver = { 1057 .driver = {
1126 .name = "aoa_codec_onyx", 1058 .name = "aoa_codec_onyx",
1127 .owner = THIS_MODULE, 1059 .owner = THIS_MODULE,
1128 }, 1060 },
1129 .attach_adapter = onyx_i2c_attach,
1130 .probe = onyx_i2c_probe, 1061 .probe = onyx_i2c_probe,
1131 .remove = onyx_i2c_remove, 1062 .remove = onyx_i2c_remove,
1132 .id_table = onyx_i2c_id, 1063 .id_table = onyx_i2c_id,
diff --git a/sound/aoa/codecs/tas.c b/sound/aoa/codecs/tas.c
index 8e63d1f35ce1..c491ae0f749c 100644
--- a/sound/aoa/codecs/tas.c
+++ b/sound/aoa/codecs/tas.c
@@ -883,43 +883,10 @@ static void tas_exit_codec(struct aoa_codec *codec)
883} 883}
884 884
885 885
886static int tas_create(struct i2c_adapter *adapter,
887 struct device_node *node,
888 int addr)
889{
890 struct i2c_board_info info;
891 struct i2c_client *client;
892
893 memset(&info, 0, sizeof(struct i2c_board_info));
894 strlcpy(info.type, "aoa_codec_tas", I2C_NAME_SIZE);
895 info.addr = addr;
896 info.platform_data = node;
897
898 client = i2c_new_device(adapter, &info);
899 if (!client)
900 return -ENODEV;
901 /*
902 * We know the driver is already loaded, so the device should be
903 * already bound. If not it means binding failed, and then there
904 * is no point in keeping the device instantiated.
905 */
906 if (!client->driver) {
907 i2c_unregister_device(client);
908 return -ENODEV;
909 }
910
911 /*
912 * Let i2c-core delete that device on driver removal.
913 * This is safe because i2c-core holds the core_lock mutex for us.
914 */
915 list_add_tail(&client->detected, &client->driver->clients);
916 return 0;
917}
918
919static int tas_i2c_probe(struct i2c_client *client, 886static int tas_i2c_probe(struct i2c_client *client,
920 const struct i2c_device_id *id) 887 const struct i2c_device_id *id)
921{ 888{
922 struct device_node *node = client->dev.platform_data; 889 struct device_node *node = client->dev.of_node;
923 struct tas *tas; 890 struct tas *tas;
924 891
925 tas = kzalloc(sizeof(struct tas), GFP_KERNEL); 892 tas = kzalloc(sizeof(struct tas), GFP_KERNEL);
@@ -953,47 +920,6 @@ static int tas_i2c_probe(struct i2c_client *client,
953 return -EINVAL; 920 return -EINVAL;
954} 921}
955 922
956static int tas_i2c_attach(struct i2c_adapter *adapter)
957{
958 struct device_node *busnode, *dev = NULL;
959 struct pmac_i2c_bus *bus;
960
961 bus = pmac_i2c_adapter_to_bus(adapter);
962 if (bus == NULL)
963 return -ENODEV;
964 busnode = pmac_i2c_get_bus_node(bus);
965
966 while ((dev = of_get_next_child(busnode, dev)) != NULL) {
967 if (of_device_is_compatible(dev, "tas3004")) {
968 const u32 *addr;
969 printk(KERN_DEBUG PFX "found tas3004\n");
970 addr = of_get_property(dev, "reg", NULL);
971 if (!addr)
972 continue;
973 return tas_create(adapter, dev, ((*addr) >> 1) & 0x7f);
974 }
975 /* older machines have no 'codec' node with a 'compatible'
976 * property that says 'tas3004', they just have a 'deq'
977 * node without any such property... */
978 if (strcmp(dev->name, "deq") == 0) {
979 const u32 *_addr;
980 u32 addr;
981 printk(KERN_DEBUG PFX "found 'deq' node\n");
982 _addr = of_get_property(dev, "i2c-address", NULL);
983 if (!_addr)
984 continue;
985 addr = ((*_addr) >> 1) & 0x7f;
986 /* now, if the address doesn't match any of the two
987 * that a tas3004 can have, we cannot handle this.
988 * I doubt it ever happens but hey. */
989 if (addr != 0x34 && addr != 0x35)
990 continue;
991 return tas_create(adapter, dev, addr);
992 }
993 }
994 return -ENODEV;
995}
996
997static int tas_i2c_remove(struct i2c_client *client) 923static int tas_i2c_remove(struct i2c_client *client)
998{ 924{
999 struct tas *tas = i2c_get_clientdata(client); 925 struct tas *tas = i2c_get_clientdata(client);
@@ -1011,16 +937,16 @@ static int tas_i2c_remove(struct i2c_client *client)
1011} 937}
1012 938
1013static const struct i2c_device_id tas_i2c_id[] = { 939static const struct i2c_device_id tas_i2c_id[] = {
1014 { "aoa_codec_tas", 0 }, 940 { "MAC,tas3004", 0 },
1015 { } 941 { }
1016}; 942};
943MODULE_DEVICE_TABLE(i2c,tas_i2c_id);
1017 944
1018static struct i2c_driver tas_driver = { 945static struct i2c_driver tas_driver = {
1019 .driver = { 946 .driver = {
1020 .name = "aoa_codec_tas", 947 .name = "aoa_codec_tas",
1021 .owner = THIS_MODULE, 948 .owner = THIS_MODULE,
1022 }, 949 },
1023 .attach_adapter = tas_i2c_attach,
1024 .probe = tas_i2c_probe, 950 .probe = tas_i2c_probe,
1025 .remove = tas_i2c_remove, 951 .remove = tas_i2c_remove,
1026 .id_table = tas_i2c_id, 952 .id_table = tas_i2c_id,