#define PWMDAC_DUTY_CYCLE_LOW 2
#define PWMDAC_DUTY_CYCLE_HIGH 3
-
-
-
#define PWMDAC_MCLK 4096000
enum pwmdac_lr_change{
PWMDAC_SAMPLE_CNT_511 = 511,
};
-
enum data_shift{
PWMDAC_DATA_LEFT_SHIFT_BIT_0 = 0,
PWMDAC_DATA_LEFT_SHIFT_BIT_1,
struct clk *audio_src;
struct clk *pwmdac_apb;
struct clk *pwmdac_mclk;
+ unsigned int pwmdac_ctrl_data;
};
-
-
-#if IS_ENABLED(CONFIG_SND_STARFIVE_PWMDAC_PCM)
+#if IS_ENABLED(CONFIG_SND_SOC_STARFIVE_PWMDAC_PCM)
void sf_pwmdac_pcm_push_tx(struct sf_pwmdac_dev *dev);
void sf_pwmdac_pcm_pop_rx(struct sf_pwmdac_dev *dev);
int sf_pwmdac_pcm_register(struct platform_device *pdev);
#ifdef CONFIG_PM_SLEEP
static int starfive_pwmdac_system_suspend(struct device *dev)
{
+ struct sf_pwmdac_dev *pwmdac = dev_get_drvdata(dev);
+
+ /* save the register value */
+ pwmdac->pwmdac_ctrl_data = pwmdc_read_reg(pwmdac->pwmdac_base, PWMDAC_CTRL);
return pm_runtime_force_suspend(dev);
}
static int starfive_pwmdac_system_resume(struct device *dev)
{
- return pm_runtime_force_resume(dev);
+ struct sf_pwmdac_dev *pwmdac = dev_get_drvdata(dev);
+ int ret;
+
+ ret = pm_runtime_force_resume(dev);
+ if (ret)
+ return ret;
+
+ /* restore the register value */
+ pwmdc_write_reg(pwmdac->pwmdac_base, PWMDAC_CTRL, pwmdac->pwmdac_ctrl_data);
+ return 0;
}
#endif