diff options
Diffstat (limited to 'sound/aoa/codecs/tas.c')
-rw-r--r-- | sound/aoa/codecs/tas.c | 80 |
1 files changed, 3 insertions, 77 deletions
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 | ||
886 | static 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 | |||
919 | static int tas_i2c_probe(struct i2c_client *client, | 886 | static 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 | ||
956 | static 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 | |||
997 | static int tas_i2c_remove(struct i2c_client *client) | 923 | static 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 | ||
1013 | static const struct i2c_device_id tas_i2c_id[] = { | 939 | static const struct i2c_device_id tas_i2c_id[] = { |
1014 | { "aoa_codec_tas", 0 }, | 940 | { "MAC,tas3004", 0 }, |
1015 | { } | 941 | { } |
1016 | }; | 942 | }; |
943 | MODULE_DEVICE_TABLE(i2c,tas_i2c_id); | ||
1017 | 944 | ||
1018 | static struct i2c_driver tas_driver = { | 945 | static 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, |