找回密码
 注册
关于网站域名变更的通知
查看: 318|回复: 0
打印 上一主题 下一主题

学习嵌入式小白基于4412修改电源管理芯片8767电压输出

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2019-12-31 15:18 | 只看该作者 |只看大图 回帖奖励 |正序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
这周技术支持的时候遇到一个小伙伴,想把底板上2.8v的输出修改为3.3v,但是不知道要从哪入手,所以,法师推文的素材就又有了~~~这位小伙伴看到记得给点个赞呐~9 {% s) o7 a3 g. t  B4 }
S5M8767电源管理芯片是三星专门针对4412研发的,S5M8767提供9路BUCK和28路LDO输出,每路电压的大小可以通过软件进行设置。这里我们以迅为-4412精英底板VDD28_AF,VDD28_CAM这俩路为例。
' N2 d  p9 ^+ V# j; G原理图分析
2 K7 t# ~/ w8 m5 t: E8 P在底板原理图中找到camera扩展端子,camera摄像头驱动中将这俩路电压设置为2.8v 的电压。所以在后面我们修改这俩路电压的时候要先去掉摄像的驱动。
通过核心板原理图可知,VDD28_AF和VDD28_CAM分别对应电源芯片 S5M8767A 的VLDO20和VLDO21。如下图所示:
然后我们打开8767的datasheet,找到对这俩路的描述,下图最上面的红框中,表示输出的电流是150mA,最低输出电压是0.8v,最大电压是3.95v。最下面的红框中,介绍的是默认输出电压,可以看到LDO20和LDO21,默认输出的是3.0v。如下图所示:
软件分析
     确定完硬件原理之后,我们知道这俩路的电压范围是0.8v到3.95v。然后我们打开内核源码里面的平台文件。
平台文件位置:
rch/ARM/mach-exynos/mach-itop4412.c7 u8 k: c8 J3 N8 p' J
然后我们找到对应ldo20和ldo21的代码,如下图所示:
我们将红框的中的代码2800000修改为3950000,红框函数中的第一个参数表示8767电源芯片的第20路,第三个参数表示输出最低电压,第四个参数表示输出最高电压。
     最后我们还要在menuconfig里面将5640的驱动去掉。这样我们软件的配置就完成了。
测试
     测试代码如下:
#include <linux/init.h>' A' F+ O: e  G. b0 q$ P
#include <linux/module.h>
) J/ X" p! X# W; f#include <linux/i2c.h>' `8 {9 Y6 A% h+ Q1 a! S( o
#include <linux/platform_device.h>8 l# n0 s5 G3 l* |5 n! m7 u
#include <linux/delay.h>
0 ?" U7 J2 e' u8 Y  c8 f#include <linux/regulator/consumer.h>. y7 T4 P9 C4 l' Y! O0 m
#include <mach/gpio.h>7 A0 X. m. [- e$ d5 D. ~
#include <plat/gpio-cfg.h>
" t7 o$ i& ~( A% v7 X. R. S#include <mach/regs-gpio.h>
7 g( ?( F- \0 m% q#include <mach/regs-clock.h>
6 @! h; Z) N# `! j) z4 t) H0 n#include <linux/fs.h>
% p1 n5 F/ M8 j  o; D$ f#include <linux/err.h>
6 ^1 J( t4 Q4 C# r% D  l. J3 t0 bstruct regulator *ov_vddaf_cam_regulator = NULL;
4 c/ Y! K/ x& `& h* {struct regulator *ov_vdd5m_cam_regulator = NULL;) {! j1 k: N& x0 e: J
struct regulator *ov_vdd18_cam_regulator = NULL;7 B9 z$ K' W8 F  w8 I% u
struct regulator *ov_vdd28_cam_regulator = NULL;
* U( [5 [3 t# ], }9 uMODULE_LICENSE("Dual BSD/GPL");
1 O! d# \) I3 ~MODULE_AUTHOR("iTOPEET_dz");' n- Z8 F+ ^$ A" S2 L
static int power(int flag)8 [. Y/ U$ O1 ~7 t$ C* E5 c
{' {9 S' B. g! Y( n7 _: E
if(1 == flag){regulator_enable(ov_vdd18_cam_regulator);. u2 f' |! W4 X9 C
udelay(10);: n8 E3 C" ^3 W5 ]% Y: S
regulator_enable(ov_vdd28_cam_regulator);. w' n; N: k1 ?
udelay(10);' L7 I7 g* d  e3 e
regulator_enable(ov_vdd5m_cam_regulator); //DOVDD DVDD 1.8v6 n  K: G2 L& ^- Y) ]( {' ?1 k
udelay(10);
- S, r# c/ ?; u  J/ B3 R8 l( `regulator_enable(ov_vddaf_cam_regulator); //AVDD 2.8v/ Q3 j& S5 d" e* T* d8 ~* F0 r
udelay(10);7 \. K, s* d3 a3 D' }" j
}
& o0 U6 F& B8 ?( T8 I1 Oelse if(0 == flag){, Z* @' j4 B" j: c/ i
regulator_disable(ov_vdd18_cam_regulator);* W: x; _. `& ~, d- k
udelay(10);
3 m* v6 D- S2 wregulator_disable(ov_vdd28_cam_regulator);
, S, j/ |, V! T3 x+ k# a9 X# qudelay(10);regulator_disable(ov_vdd5m_cam_regulator);
' ?% O5 @$ }" l6 m# A! L7 f" p' Sudelay(10);regulator_disable(ov_vddaf_cam_regulator);
$ x0 e) z. ]6 i$ h. Kudelay(10);9 V) R: {3 c7 i; p( E- [* ^" G) ?
}
6 J! ~, e! s1 E: k4 Treturn 0 ;
8 {* x$ g( T/ `: g0 e}" X' B* x3 c+ x% j) W- P. [; n+ {& P
static void power_init(void)
4 |$ O4 U8 z/ T6 ]{
% }* P5 u* Y1 P: u0 fint ret;( X4 m+ ]6 t  J6 h
ov_vdd18_cam_regulator = regulator_get(NULL, "vdd18_cam");  [1 g: h7 [! }" R) ?% ?5 }* C
if (IS_ERR(ov_vdd18_cam_regulator)) {
7 ]. ~2 V1 [) w+ Yprintk("%s: failed to get %s\n", __func__, "vdd18_cam");* J, K0 U1 m6 n
ret = -ENODEV;- d( ?4 E( X: K! o5 _( k
goto err_regulator;}ov_vdd28_cam_regulator = regulator_get(NULL, "vdda28_2m");
" C" {3 k4 q2 A7 oif (IS_ERR(ov_vdd28_cam_regulator)) {
/ W; c' R$ H' C: H2 l( Z) Rprintk("%s: failed to get %s\n", __func__, "vdda28_2m");. `! A! D, ^" F  @5 F# z8 x7 r
ret = -ENODEV;
! g; N  x% u" K) ?1 wgoto err_regulator;/ a+ H( A8 A, _7 g
}
* _& V; y9 ~2 H! n, L; bov_vddaf_cam_regulator = regulator_get(NULL, "vdd28_af");# j9 A& g3 E3 U8 \$ e
if (IS_ERR(ov_vddaf_cam_regulator)) {
2 W5 X" w3 G% e& [printk("%s: failed to get %s\n", __func__, "vdd28_af");
! m& P  D1 N# Y, j3 M) dret = -ENODEV;goto err_regulator;
2 d( e& U" H" B& I}
0 L* r$ I4 c1 [: v" X/ x0 z/ ?  }ov_vdd5m_cam_regulator = regulator_get(NULL, "vdd28_cam");
& g: \) O; E& U& Oif (IS_ERR(ov_vdd5m_cam_regulator)) {" v. ]! t0 D/ V6 ^* M* o
printk("%s: failed to get %s\n", __func__, "vdd28_cam");! q: N! \. N6 x1 D
ret = -ENODEV;goto err_regulator;  f# W9 q; {2 @" a7 M4 B
}& c% X- U7 B6 |& W. L! k
err_regulator:0 P0 O  y) u( {
regulator_put(ov_vddaf_cam_regulator);
& ]/ I) a* h, G3 N! y2 b. Uregulator_put(ov_vdd5m_cam_regulator);' H* S. S8 R+ ~4 Y
regulator_put(ov_vdd18_cam_regulator);( y8 k; ]+ @) I3 S) Q
regulator_put(ov_vdd28_cam_regulator);
6 J# w: }1 n: H4 O2 u- [0 x}
+ M7 _  y$ H: ^* D& Lstatic int hello_init(void)' V$ h0 d* b  `: l1 W
{
; w/ `4 @: t2 G7 t+ Bpower_init();
( W9 ?, L- b0 j$ zpower(1);8 H& Z' ~' @! H! c) q
printk(KERN_EMERG "Hello World enter!\n");
6 R% p( V3 m. i3 c8 Z# `, @; K2 Sreturn 0;
. o( \6 }' y: ~}
; R- [; j! V! W; p* _$ o2 A0 jstatic void hello_exit(void)
. y9 d$ ~! x. z{
0 }: T2 G/ B2 N; h( Jpower(0);3 l% C& o2 ]  q( k+ C  a# [
printk(KERN_EMERG "Hello world exit!\n");3 h; Q5 @/ |8 S7 |! ]6 ?8 q, g
}
2 Z7 o, y+ Z% W- }" F: Rmodule_init(hello_init);
( t3 f- X7 v: w' s4 V* b5 dmodule_exit(hello_exit);1 Z' t/ B: t# J7 E' P

8 H/ C* Z0 u. h: ]$ BMakefile如下所示。
: a! H0 B9 U7 n% G1 P6 x#!/bin/bash
" S( g6 N0 [6 \$ i, pobj-m += power_s5m8767a_test.o9 b8 m  O) a; y
KDIR := /home/topeet/android4.0/iTop4412_Kernel_3.0" w* h. R: T+ x  N+ q7 u2 X
PWD ?= $(shell pwd)
- j* Y$ f3 z  [. Dall:5 X8 U  {5 W* v: ?6 C, z
make -C $(KDIR) M=$(PWD) modules- Y1 k, r/ c# V# |
clean:
1 w6 P* T: o6 \1 {4 F  Wrm -RF *.o modules.order *.ko *mod.c Module.symvers
9 K2 Q+ s, ~8 F; R我们加载驱动之后,测量电压大约为3V左右,有压降,卸载驱动之后,电压为0。说明驱动运行成功,如果在自己的项目中,假如需要用到电源控制,也可以参考本例程来实现。

9 E0 W" F9 K% W+ |! |7 q
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-11-25 14:04 , Processed in 0.203125 second(s), 29 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表