static void mx_power_off(void) { struct task_struct *task = get_current(); char task_com[TASK_COMM_LEN]; int regs; int gpio; pr_emerg("func:%s, process is:%d:%s\n", __func__, task->pid, get_task_comm(task_com, task)); if (task->parent) { task = task->parent; pr_emerg("func:%s, parent:%d:%s\n", __func__, task->pid, get_task_comm(task_com, task)); if (task->parent) { task = task->parent; pr_emerg("func:%s, pparent:%d:%s\n", __func__, task->pid, get_task_comm(task_com, task)); } } if (machine_is_m030()) gpio = EXYNOS4_GPX2(5); else gpio = EXYNOS4_GPX0(3); mx_disable_inand(); if (gpio_get_value(gpio)) { /* 1. Check reboot charging */ mx_reboot_internal("charge"); } else { /* 2. Power off */ regs = __raw_readl(S5P_PS_HOLD_CONTROL); /* dead loop to avoid sometimes auto restart*/ while(1) { pr_emerg("%s: waiting for power off\n", __func__); __raw_writel(regs & 0xFFFFFEFF, S5P_PS_HOLD_CONTROL); } } }
static int wm8994_i2c_probe(struct i2c_client *i2c, const struct i2c_device_id *id) { struct wm8994 *wm8994; wm8994 = kzalloc(sizeof(struct wm8994), GFP_KERNEL); if (wm8994 == NULL) return -ENOMEM; i2c_set_clientdata(i2c, wm8994); wm8994->dev = &i2c->dev; wm8994->control_data = i2c; wm8994->read_dev = wm8994_i2c_read_device; wm8994->write_dev = wm8994_i2c_write_device; wm8994->irq = i2c->irq; wm8994->type = id->driver_data; #ifdef CONFIG_MACH_M030 if(machine_is_m030()) { wm8994->crystal_regulator = regulator_get(wm8994->dev, "audio_crystal"); if(IS_ERR(wm8994->crystal_regulator)) pr_err("failed to get regulator [%s]\n", "audio_crystal"); else regulator_enable(wm8994->crystal_regulator); } #endif return wm8994_device_init(wm8994, i2c->irq); }
static int __init mx_init_camera(void) { #ifdef CONFIG_VIDEO_M6MO if (machine_is_m030()) i2c_devs7[0].irq = M030_GPIO_CAMERA0_EINT; #endif s3c_i2c7_set_platdata(NULL); i2c_register_board_info(7, i2c_devs7, ARRAY_SIZE(i2c_devs7)); #ifdef CONFIG_VIDEO_FIMC s3c_fimc0_set_platdata(&fimc_plat); s3c_fimc1_set_platdata(NULL); s3c_fimc2_set_platdata(NULL); s3c_fimc3_set_platdata(NULL); #ifndef CONFIG_PM_GENERIC_DOMAINS s3c_device_fimc0.dev.parent = &exynos4_device_pd[PD_CAM].dev; s3c_device_fimc1.dev.parent = &exynos4_device_pd[PD_CAM].dev; s3c_device_fimc2.dev.parent = &exynos4_device_pd[PD_CAM].dev; s3c_device_fimc3.dev.parent = &exynos4_device_pd[PD_CAM].dev; #endif #endif #ifdef CONFIG_VIDEO_FIMC_MIPI s3c_csis0_set_platdata(NULL); #ifndef CONFIG_PM_GENERIC_DOMAINS s3c_device_csis0.dev.parent = &exynos4_device_pd[PD_CAM].dev; #endif #endif return 0; }
static inline void set_wakeup_type(mx_int_type group, int pending) { if(machine_is_m030()) m030_set_wakeup_type(group, pending); else if (machine_is_m032() || machine_is_m031()) m032_set_wakeup_type(group, pending); else pr_err("Unknow machine type\n"); }
int m6mo_mipi_cam_power(int enable) { struct regulator_bulk_data supplies[5]; int num_consumers = ARRAY_SIZE(supplies); unsigned int gpio, front_gpio; int ret; pr_info("%s():%d\n", __FUNCTION__, enable); if (machine_is_m030()) { supplies[0].supply = "cam_isp_1.8v"; supplies[1].supply = "cam_isp_core"; supplies[2].supply = "cam_sensor_2.7v"; supplies[3].supply = "cam_sensor_1.2v"; supplies[4].supply = "cam_af_2.7v"; gpio = M030_GPIO_CAMERA0_RST; front_gpio = M030_GPIO_CAMERA1_PDN; } else { supplies[0].supply = "cam_1.8v"; supplies[1].supply = "cam0_isp_1.2v"; supplies[2].supply = "cam0_sensor_1.2v"; supplies[3].supply = "cam0_sensor_2.7v"; supplies[4].supply = "cam0_af_2.7v"; gpio = BACK_CAM_RST; front_gpio = FRONT_CAM_DOWN; } ret = regulator_bulk_get(NULL, num_consumers, supplies); if (ret) { pr_err("%s():regulator_bulk_get failed\n", __func__); return ret; } if (enable) { gpio_set_value(front_gpio, 1); ret = regulator_bulk_enable(num_consumers, supplies); gpio_set_value(gpio, 1); } else { gpio_set_value(gpio, 0); ret = regulator_bulk_disable(num_consumers, supplies); gpio_set_value(front_gpio, 0); } if (ret) { pr_err("%s():regulator_bulk_%sable failed\n", __func__, enable?"en":"dis"); goto exit_regulator; } usleep_range(5000, 5000); exit_regulator: regulator_bulk_free(num_consumers, supplies); return ret; }
static int ov7690_init(struct device *dev) { struct clk *srclk, *clk; unsigned int gpio; int ret = 0; /* source clk for MCLK*/ srclk = clk_get(dev, "xusbxti"); if (IS_ERR(srclk)) { dev_err(dev, "failed to get srclk source\n"); return -EINVAL; } /* mclk */ clk = clk_get(dev, "sclk_cam0"); if (IS_ERR(clk)) { dev_err(dev, "failed to get mclk source\n"); ret = -EINVAL; goto exit_clkget_cam; } if (clk_set_parent(clk, srclk)) { dev_err(dev, "unable to set parent.\n"); ret = -EINVAL; goto exit_clkset_parent; } clk_set_rate(clk, 24000000); /* ov7690 power down pin should be initialized to high, * or the back camera can not get the i2c bus sometime */ if (machine_is_m030()) gpio = M030_GPIO_CAMERA1_PDN; else gpio = FRONT_CAM_DOWN; ret = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, "OV7690_PWDN"); if (ret) { pr_err("%s():gpio_request failed\n", __func__); goto exit_clkset_parent; } exit_clkset_parent: clk_put(clk); exit_clkget_cam: clk_put(srclk); return ret; }
static int m6mo_init(struct device *dev) { struct clk *srclk, *clk; unsigned int gpio; int ret = 0; /* source clk for MCLK*/ srclk = clk_get(dev, "xusbxti"); if (IS_ERR(srclk)) { dev_err(dev, "failed to get srclk source\n"); return -EINVAL; } /* mclk */ clk = clk_get(dev, "sclk_cam0"); if (IS_ERR(clk)) { dev_err(dev, "failed to get mclk source\n"); ret = -EINVAL; goto exit_clkget_cam; } if (clk_set_parent(clk, srclk)) { dev_err(dev, "unable to set parent.\n"); ret = -EINVAL; goto exit_clkset_parent; } clk_set_rate(clk, 24000000); if (machine_is_m030()) gpio = M030_GPIO_CAMERA0_RST; else gpio = BACK_CAM_RST; /*m6mo reset pin shoud be initialized to low*/ ret = gpio_request_one(gpio, GPIOF_OUT_INIT_LOW, "M6MO_RESET"); if (ret) { pr_err("%s():gpio_request failed\n", __func__); goto exit_clkset_parent; } exit_clkset_parent: clk_put(clk); exit_clkget_cam: clk_put(srclk); return ret; }
static int ov7690_cam_power(int enable) { struct regulator_bulk_data supplies[2]; int num_consumers = ARRAY_SIZE(supplies); unsigned int gpio; int ret; pr_info("%s():%d\n", __FUNCTION__, enable); if (machine_is_m030()) { supplies[0].supply = "cam_isp_1.8v"; supplies[1].supply = "cam_front_2.8v"; gpio = M030_GPIO_CAMERA1_PDN; } else { supplies[0].supply = "cam_1.8v"; supplies[1].supply = "cam1_2.8v"; gpio = FRONT_CAM_DOWN; } ret = regulator_bulk_get(NULL, num_consumers, supplies); if (ret) { pr_err("%s():regulator_bulk_get failed\n", __func__); return ret; } if (enable) { ret = regulator_bulk_enable(num_consumers, supplies); } else { ret = regulator_bulk_disable(num_consumers, supplies); } if (ret) { pr_err("%s():regulator_bulk_%sable failed\n", __func__, enable?"en":"dis"); goto exit_regulator; } usleep_range(5000, 5000); exit_regulator: regulator_bulk_free(num_consumers, supplies); return ret; }
static int mx_wm8958_aif1_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *codec_dai = rtd->codec_dai; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; unsigned long rclk; int bfs, rfs, ret; printk("++%s format = %d rate = %d\n", __func__,params_format(params),(params_rate(params))); switch (params_format(params)) { case SNDRV_PCM_FORMAT_U24: case SNDRV_PCM_FORMAT_S24: bfs = 48; break; case SNDRV_PCM_FORMAT_U16_LE: case SNDRV_PCM_FORMAT_S16_LE: bfs = 32; break; default: return -EINVAL; } switch (params_rate(params)) { case 16000: case 22050: case 24000: case 32000: case 44100: case 48000: case 88200: case 96000: if (bfs == 48) rfs = 384; else rfs = 256; break; case 64000: rfs = 384; break; case 8000: case 11025: case 12000: if (bfs == 48) rfs = 768; else rfs = 512; break; default: return -EINVAL; } rclk = params_rate(params) * rfs; /* Set the codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); if (ret < 0) return ret; /* Set the cpu DAI configuration */ ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF | SND_SOC_DAIFMT_CBM_CFM); if (ret < 0) return ret; ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL1, rclk, SND_SOC_CLOCK_IN); if (ret < 0) return ret; if (machine_is_m030()) { ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, WM8994_FLL_SRC_MCLK1, WM8994_FREQ_12000000, rclk); if (ret < 0) return ret; } else { ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL1, WM8994_FLL_SRC_MCLK1, WM8994_FREQ_24000000, rclk); if (ret < 0) return ret; } ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_OPCLK, rclk, MOD_OPCLK_PCLK);//select audio bus clock if (ret < 0) return ret; ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_RCLKSRC_0,//SAMSUNG_I2S_RCLKSRC_0 = Using BUSCLK,SAMSUNG_I2S_RCLKSRC_1 = Using I2SCLK rclk, 0); if (ret < 0) return ret; ret = snd_soc_dai_set_sysclk(cpu_dai, SAMSUNG_I2S_CDCLK,//RCLK supply to codec, set RFS rfs, SND_SOC_CLOCK_OUT); if (ret < 0) return ret; ret = snd_soc_dai_set_clkdiv(cpu_dai, SAMSUNG_I2S_DIV_BCLK, bfs);//set BFS if (ret < 0) return ret; printk("--%s\n", __func__); return 0; }
static int mx_wm8958_aif2_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params) { struct snd_soc_pcm_runtime *rtd = substream->private_data; struct snd_soc_dai *cpu_dai = rtd->cpu_dai; struct snd_soc_dai *codec_dai = rtd->codec_dai; #ifdef CONFIG_SND_SAMSUNG_PCM_USE_EPLL unsigned long epll_out_rate; #endif /* CONFIG_SND_SAMSUNG_PCM_USE_EPLL */ int rfs, ret; printk("++%s format = %d rate = %d\n", __func__,params_format(params),(params_rate(params))); #ifdef CONFIG_SND_SAMSUNG_PCM_USE_EPLL switch (params_rate(params)) { case 8000: case 12000: case 16000: case 24000: case 32000: case 48000: case 64000: case 96000: epll_out_rate = 49152000; break; case 11025: case 22050: case 44100: case 88200: epll_out_rate = 67737600; break; default: printk(KERN_ERR "%s:%d Sampling Rate %u not supported!\n", __func__, __LINE__, params_rate(params)); return -EINVAL; } #endif /* CONFIG_SND_SAMSUNG_PCM_USE_EPLL */ switch (params_rate(params)) { case 16000: case 22050: case 22025: case 32000: case 44100: case 48000: case 96000: case 24000: #ifdef CONFIG_SND_SAMSUNG_PCM_USE_EPLL rfs = 256; #else /* CONFIG_SND_SAMSUNG_PCM_USE_EPLL */ rfs = 384; #endif /* CONFIG_SND_SAMSUNG_PCM_USE_EPLL */ break; case 64000: rfs = 384; break; case 11025: case 12000: rfs = 512; break; case 8000: case 88200: rfs = 128; break; default: printk(KERN_ERR "%s:%d Sampling Rate %u not supported!\n", __func__, __LINE__, params_rate(params)); return -EINVAL; } /* Set the codec DAI configuration */ ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS); if (ret < 0) return ret; /* Set the cpu DAI configuration */ ret = snd_soc_dai_set_fmt(cpu_dai, SND_SOC_DAIFMT_DSP_A | SND_SOC_DAIFMT_IB_NF | SND_SOC_DAIFMT_CBS_CFS); if (ret < 0) return ret; #ifdef CONFIG_SND_SAMSUNG_PCM_USE_EPLL /* * Samsung SoCs PCM has no MCLK(rclk) output support, so codec * should have to make its own MCLK with FLL(or PLL) from other * clock source. */ ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_FLL2, params_rate(params)*rfs, SND_SOC_CLOCK_IN); if (ret < 0) return ret; if (machine_is_m030()) { ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL2, WM8994_FLL_SRC_MCLK1, WM8994_FREQ_12000000, params_rate(params)*rfs); } else{ ret = snd_soc_dai_set_pll(codec_dai, WM8994_FLL2, WM8994_FLL_SRC_MCLK1, WM8994_FREQ_24000000, params_rate(params)*rfs); } if (ret < 0) return ret; #else ret = snd_soc_dai_set_sysclk(codec_dai, WM8994_SYSCLK_MCLK2, params_rate(params)*rfs, SND_SOC_CLOCK_IN); if (ret < 0) return ret; #endif /* CONFIG_SND_SAMSUNG_PCM_USE_EPLL */ #ifdef CONFIG_SND_SAMSUNG_PCM_USE_EPLL /* Set EPLL clock rate */ ret = set_epll_rate(epll_out_rate); if (ret < 0) return ret; #endif /* CONFIG_SND_SAMSUNG_PCM_USE_EPLL */ /* Set SCLK_DIV for making bclk */ ret = snd_soc_dai_set_clkdiv(cpu_dai, S3C_PCM_SCLK_PER_FS, rfs); if (ret < 0) return ret; printk("--%s\n", __func__); return 0; }