diff options
author | Leon Romanovsky <leon@leon.nu> | 2011-11-17 05:01:30 -0500 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2011-11-17 11:48:18 -0500 |
commit | 277c01bb45a4924b1741fd41c353860e8d530f6f (patch) | |
tree | 2b867d08f08f8a33edd428575443046d0f32f248 /sound/soc/codecs/alc5632.c | |
parent | 9b4156cbe9c18605d42ecf80bb99364d0c5b884a (diff) |
ASoC: alc5632: Update of i2c_probe function to use regmap API only
Signed-off-by: Leon Romanovsky <leon@leon.nu>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'sound/soc/codecs/alc5632.c')
-rw-r--r-- | sound/soc/codecs/alc5632.c | 67 |
1 files changed, 30 insertions, 37 deletions
diff --git a/sound/soc/codecs/alc5632.c b/sound/soc/codecs/alc5632.c index be102281c0a7..c32eadebb762 100644 --- a/sound/soc/codecs/alc5632.c +++ b/sound/soc/codecs/alc5632.c | |||
@@ -1053,48 +1053,14 @@ static __devinit int alc5632_i2c_probe(struct i2c_client *client, | |||
1053 | const struct i2c_device_id *id) | 1053 | const struct i2c_device_id *id) |
1054 | { | 1054 | { |
1055 | struct alc5632_priv *alc5632; | 1055 | struct alc5632_priv *alc5632; |
1056 | int ret, vid1, vid2; | 1056 | int ret, ret1, ret2; |
1057 | 1057 | unsigned int vid1, vid2; | |
1058 | vid1 = i2c_smbus_read_word_data(client, ALC5632_VENDOR_ID1); | ||
1059 | if (vid1 < 0) { | ||
1060 | dev_err(&client->dev, "failed to read I2C\n"); | ||
1061 | return -EIO; | ||
1062 | } else { | ||
1063 | dev_info(&client->dev, "got vid1: %x\n", vid1); | ||
1064 | } | ||
1065 | vid1 = ((vid1 & 0xff) << 8) | (vid1 >> 8); | ||
1066 | |||
1067 | vid2 = i2c_smbus_read_word_data(client, ALC5632_VENDOR_ID2); | ||
1068 | if (vid2 < 0) { | ||
1069 | dev_err(&client->dev, "failed to read I2C\n"); | ||
1070 | return -EIO; | ||
1071 | } else { | ||
1072 | dev_info(&client->dev, "got vid2: %x\n", vid2); | ||
1073 | } | ||
1074 | vid2 = (vid2 & 0xff); | ||
1075 | |||
1076 | if ((vid1 != 0x10ec) || (vid2 != id->driver_data)) { | ||
1077 | dev_err(&client->dev, "unknown or wrong codec\n"); | ||
1078 | dev_err(&client->dev, "Expected %x:%lx, got %x:%x\n", | ||
1079 | 0x10ec, id->driver_data, | ||
1080 | vid1, vid2); | ||
1081 | return -ENODEV; | ||
1082 | } | ||
1083 | 1058 | ||
1084 | alc5632 = devm_kzalloc(&client->dev, | 1059 | alc5632 = devm_kzalloc(&client->dev, |
1085 | sizeof(struct alc5632_priv), GFP_KERNEL); | 1060 | sizeof(struct alc5632_priv), GFP_KERNEL); |
1086 | if (alc5632 == NULL) | 1061 | if (alc5632 == NULL) |
1087 | return -ENOMEM; | 1062 | return -ENOMEM; |
1088 | 1063 | ||
1089 | alc5632->id = vid2; | ||
1090 | switch (alc5632->id) { | ||
1091 | case 0x5c: | ||
1092 | alc5632_dai.name = "alc5632-hifi"; | ||
1093 | break; | ||
1094 | default: | ||
1095 | return -EINVAL; | ||
1096 | } | ||
1097 | |||
1098 | i2c_set_clientdata(client, alc5632); | 1064 | i2c_set_clientdata(client, alc5632); |
1099 | 1065 | ||
1100 | alc5632->regmap = regmap_init_i2c(client, &alc5632_regmap); | 1066 | alc5632->regmap = regmap_init_i2c(client, &alc5632_regmap); |
@@ -1104,6 +1070,24 @@ static __devinit int alc5632_i2c_probe(struct i2c_client *client, | |||
1104 | return ret; | 1070 | return ret; |
1105 | } | 1071 | } |
1106 | 1072 | ||
1073 | ret1 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID1, &vid1); | ||
1074 | ret2 = regmap_read(alc5632->regmap, ALC5632_VENDOR_ID2, &vid2); | ||
1075 | if (ret1 != 0 || ret2 != 0) { | ||
1076 | dev_err(&client->dev, | ||
1077 | "Failed to read chip ID: ret1=%d, ret2=%d\n", ret1, ret2); | ||
1078 | regmap_exit(alc5632->regmap); | ||
1079 | return -EIO; | ||
1080 | } | ||
1081 | |||
1082 | vid2 >>= 8; | ||
1083 | |||
1084 | if ((vid1 != 0x10EC) || (vid2 != id->driver_data)) { | ||
1085 | dev_err(&client->dev, | ||
1086 | "Device is not a ALC5632: VID1=0x%x, VID2=0x%x\n", vid1, vid2); | ||
1087 | regmap_exit(alc5632->regmap); | ||
1088 | return -EINVAL; | ||
1089 | } | ||
1090 | |||
1107 | ret = alc5632_reset(alc5632->regmap); | 1091 | ret = alc5632_reset(alc5632->regmap); |
1108 | if (ret < 0) { | 1092 | if (ret < 0) { |
1109 | dev_err(&client->dev, "Failed to issue reset\n"); | 1093 | dev_err(&client->dev, "Failed to issue reset\n"); |
@@ -1111,7 +1095,16 @@ static __devinit int alc5632_i2c_probe(struct i2c_client *client, | |||
1111 | return ret; | 1095 | return ret; |
1112 | } | 1096 | } |
1113 | 1097 | ||
1114 | ret = snd_soc_register_codec(&client->dev, | 1098 | alc5632->id = vid2; |
1099 | switch (alc5632->id) { | ||
1100 | case 0x5c: | ||
1101 | alc5632_dai.name = "alc5632-hifi"; | ||
1102 | break; | ||
1103 | default: | ||
1104 | return -EINVAL; | ||
1105 | } | ||
1106 | |||
1107 | ret = snd_soc_register_codec(&client->dev, | ||
1115 | &soc_codec_device_alc5632, &alc5632_dai, 1); | 1108 | &soc_codec_device_alc5632, &alc5632_dai, 1); |
1116 | 1109 | ||
1117 | if (ret < 0) { | 1110 | if (ret < 0) { |