Skip to content

Commit

Permalink
sgtl5000 hacks
Browse files Browse the repository at this point in the history
Signed-off-by: Russell King <[email protected]>
  • Loading branch information
Russell King authored and linux4kix committed Jul 13, 2014
1 parent 61f693f commit dd4bf6a
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 7 deletions.
48 changes: 44 additions & 4 deletions arch/arm/boot/dts/imx6dl-hummingboard.dts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@
};
};

sound-sgtl5000 {
audio-codec = <&sgtl5000>;
audio-routing =
"MIC_IN", "Mic Jack",
"Mic Jack", "Mic Bias",
"Headphone Jack", "HP_OUT";
compatible = "fsl,imx-audio-sgtl5000";
model = "On-board Codec";
mux-ext-port = <5>;
mux-int-port = <1>;
ssi-controller = <&ssi1>;
};

sound-spdif {
compatible = "fsl,imx-audio-spdif";
model = "On-board SPDIF";
Expand All @@ -65,6 +78,10 @@
};
};

&audmux {
status = "okay";
};

&can1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hummingboard_flexcan1>;
Expand All @@ -74,16 +91,24 @@
&i2c1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hummingboard_i2c1>;

/*
* Not fitted on Carrier-1 board... yet
status = "okay";

/* Pro model */
rtc: pcf8523@68 {
compatible = "nxp,pcf8523";
reg = <0x68>;
};
*/

/* Pro model */
sgtl5000: sgtl5000@0a {
clocks = <&clks 201>;
compatible = "fsl,sgtl5000";
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_hummingboard_sgtl5000>;
reg = <0x0a>;
VDDA-supply = <&reg_3p3v>;
VDDIO-supply = <&reg_3p3v>;
};
};

&iomuxc {
Expand All @@ -108,6 +133,16 @@
>;
};

pinctrl_hummingboard_sgtl5000: hummingboard-sgtl5000 {
fsl,pins = <
MX6QDL_PAD_DISP0_DAT19__AUD5_RXD 0x130b0 /*brk*/
MX6QDL_PAD_KEY_COL0__AUD5_TXC 0x130b0 /*ok*/
MX6QDL_PAD_KEY_ROW0__AUD5_TXD 0x110b0 /*brk*/
MX6QDL_PAD_KEY_COL1__AUD5_TXFS 0x130b0 /*ok*/
MX6QDL_PAD_GPIO_5__CCM_CLKO1 0x130b0
>;
};

pinctrl_hummingboard_spdif: hummingboard-spdif {
fsl,pins = <MX6QDL_PAD_GPIO_17__SPDIF_OUT 0x13091>;
};
Expand Down Expand Up @@ -153,6 +188,11 @@
status = "okay";
};

&ssi1 {
fsl,mode = "i2s-slave";
status = "okay";
};

&usbh1 {
disable-over-current;
vbus-supply = <&reg_usbh1_vbus>;
Expand Down
25 changes: 22 additions & 3 deletions sound/soc/codecs/sgtl5000.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ static int ldo_regulator_enable(struct regulator_dev *dev)
struct ldo_regulator *ldo = rdev_get_drvdata(dev);
struct snd_soc_codec *codec = (struct snd_soc_codec *)ldo->codec_data;
int reg;

dev_info(codec->dev, "%s(): enabled %u\n", __func__, ldo->enabled);
if (ldo_regulator_is_enabled(dev))
return 0;

Expand Down Expand Up @@ -788,10 +788,16 @@ static int ldo_regulator_disable(struct regulator_dev *dev)
{
struct ldo_regulator *ldo = rdev_get_drvdata(dev);
struct snd_soc_codec *codec = (struct snd_soc_codec *)ldo->codec_data;
dev_info(codec->dev, "%s(): enabled %u\n", __func__, ldo->enabled);

snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
SGTL5000_LINREG_SIMPLE_POWERUP,
SGTL5000_LINREG_SIMPLE_POWERUP);

snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
SGTL5000_LINEREG_D_POWERUP,
0);
dev_info(codec->dev, "%s: ANA_POWER = 0x%04x\n", __func__, snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER));

/* clear voltage info */
snd_soc_update_bits(codec, SGTL5000_CHIP_LINREG_CTRL,
Expand Down Expand Up @@ -849,6 +855,7 @@ static int ldo_regulator_register(struct snd_soc_codec *codec,
config.dev = codec->dev;
config.driver_data = ldo;
config.init_data = init_data;
config.ena_gpio = -EINVAL;

ldo->dev = regulator_register(&ldo->desc, &config);
if (IS_ERR(ldo->dev)) {
Expand Down Expand Up @@ -1202,8 +1209,11 @@ static int sgtl5000_set_power_regs(struct snd_soc_codec *codec)
* if vddio and vddd > 3.1v,
* charge pump should be clean before set ana_pwr
*/
snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
SGTL5000_VDDC_CHRGPMP_POWERUP, 0);
// FIXME: this is total crap - we have read this register above into
// ana_pwr, which we then modify (above), and then write back to the
// register below. This modification just gets completely overwritten.
// snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER,
// SGTL5000_VDDC_CHRGPMP_POWERUP, 0);

/* VDDC use VDDIO rail */
lreg_ctrl |= SGTL5000_VDDC_ASSN_OVRD;
Expand Down Expand Up @@ -1355,6 +1365,9 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
return ret;
}

if (!devres_open_group(codec->dev, NULL, GFP_KERNEL))
return -ENOMEM;

ret = sgtl5000_enable_regulators(codec);
if (ret)
return ret;
Expand Down Expand Up @@ -1412,6 +1425,9 @@ static int sgtl5000_probe(struct snd_soc_codec *codec)
err:
regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);

devres_release_group(codec->dev, NULL);

ldo_regulator_remove(codec);

return ret;
Expand All @@ -1425,6 +1441,9 @@ static int sgtl5000_remove(struct snd_soc_codec *codec)

regulator_bulk_disable(ARRAY_SIZE(sgtl5000->supplies),
sgtl5000->supplies);

devres_release_group(codec->dev, NULL);

ldo_regulator_remove(codec);

return 0;
Expand Down

0 comments on commit dd4bf6a

Please sign in to comment.