ASoC: rockchip: i2s: add support for i2s bclk fs configuration
authorSugar Zhang <sugar.zhang@rock-chips.com>
Mon, 26 Dec 2016 06:11:45 +0000 (14:11 +0800)
committerHuang, Tao <huangtao@rock-chips.com>
Mon, 26 Dec 2016 09:50:51 +0000 (17:50 +0800)
this patch add support for i2s bclk fs configuration, we can
configure bclk_fs by devicetree as required.

Change-Id: I7e034e0466793b5b9eab6566a43e90213f219bb0
Signed-off-by: Sugar Zhang <sugar.zhang@rock-chips.com>
Documentation/devicetree/bindings/sound/rockchip-i2s.txt
sound/soc/rockchip/rockchip_i2s.c

index 4ea29aa9af59a86d34577329835b8437e72bd86e..ebb54bd168da7fccfdbba2393900497b5911e2b5 100644 (file)
@@ -22,6 +22,7 @@ Required properties:
    - "i2s_clk" : clock for I2S controller
 - rockchip,playback-channels: max playback channels, if not set, 8 channels default.
 - rockchip,capture-channels: max capture channels, if not set, 2 channels default.
+- rockchip,bclk-fs: configure the i2s bclk fs.
 
 Required properties for controller which support multi channels
 playback/capture:
@@ -40,4 +41,5 @@ i2s@ff890000 {
        clocks = <&cru HCLK_I2S0>, <&cru SCLK_I2S0>;
        rockchip,playback-channels = <8>;
        rockchip,capture-channels = <2>;
+       rockchip,bclk-fs = <64>;
 };
index d2d66f0b9e1f038e744a119abf32d515525bb022..f66ce65c24cef8758ee9a61fc08d7b9f11b20432 100644 (file)
@@ -51,6 +51,7 @@ struct rk_i2s_dev {
        bool rx_start;
        bool is_master_mode;
        const struct rk_i2s_pins *pins;
+       unsigned int bclk_fs;
 };
 
 static int i2s_runtime_suspend(struct device *dev)
@@ -252,7 +253,7 @@ static int rockchip_i2s_hw_params(struct snd_pcm_substream *substream,
 
        if (i2s->is_master_mode) {
                mclk_rate = clk_get_rate(i2s->mclk);
-               bclk_rate = 2 * 32 * params_rate(params);
+               bclk_rate = i2s->bclk_fs * params_rate(params);
                if (bclk_rate && mclk_rate % bclk_rate)
                        return -EINVAL;
 
@@ -631,6 +632,12 @@ static int rockchip_i2s_probe(struct platform_device *pdev)
                        soc_dai->capture.channels_max = val;
        }
 
+       i2s->bclk_fs = 64;
+       if (!of_property_read_u32(node, "rockchip,bclk-fs", &val)) {
+               if ((val >= 32) && (val % 2 == 0))
+                       i2s->bclk_fs = val;
+       }
+
        ret = devm_snd_soc_register_component(&pdev->dev,
                                              &rockchip_i2s_component,
                                              soc_dai, 1);