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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
这周技术支持的时候遇到一个小伙伴,想把底板上2.8v的输出修改为3.3v,但是不知道要从哪入手,所以,法师推文的素材就又有了~~~这位小伙伴看到记得给点个赞呐~
# U1 j9 Y+ J' C6 a0 lS5M8767电源管理芯片是三星专门针对4412研发的,S5M8767提供9路BUCK和28路LDO输出,每路电压的大小可以通过软件进行设置。这里我们以迅为-4412精英底板VDD28_AF,VDD28_CAM这俩路为例。
2 r' W& T2 C3 s, }原理图分析' N/ S8 Q! g5 q" I, U. c
在底板原理图中找到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.c' W9 z2 Y# L6 w
然后我们找到对应ldo20和ldo21的代码,如下图所示:
我们将红框的中的代码2800000修改为3950000,红框函数中的第一个参数表示8767电源芯片的第20路,第三个参数表示输出最低电压,第四个参数表示输出最高电压。
     最后我们还要在menuconfig里面将5640的驱动去掉。这样我们软件的配置就完成了。
测试
     测试代码如下:
#include <linux/init.h>. x- Q) P) P6 y5 w
#include <linux/module.h>
9 I- F2 I% ^5 u#include <linux/i2c.h>" \; o* N9 l/ G0 Q
#include <linux/platform_device.h>
4 `  H( w6 L2 b#include <linux/delay.h>+ W# |9 k/ M* L- F' L4 i
#include <linux/regulator/consumer.h>  w. i* O, J/ x/ x8 `) x; S
#include <mach/gpio.h>
0 O1 ]$ o. k0 m  M/ }% W) A6 V/ l#include <plat/gpio-cfg.h>
1 g  o" `* i7 b. K1 s- N: t9 W$ i3 ]#include <mach/regs-gpio.h>* {3 x% L" @+ }. r) {
#include <mach/regs-clock.h>1 `( x- c9 e- A1 `7 Z
#include <linux/fs.h>
/ F; q6 x, M; ]* h1 s4 Q1 Z#include <linux/err.h>
  f9 W" V9 i. v8 K3 f! ^; }struct regulator *ov_vddaf_cam_regulator = NULL;# @+ z* N3 h6 f0 J' P
struct regulator *ov_vdd5m_cam_regulator = NULL;
0 s# M% c% }* I+ i9 J$ `struct regulator *ov_vdd18_cam_regulator = NULL;
, y# B  H5 G* A0 n) _struct regulator *ov_vdd28_cam_regulator = NULL;# O9 W# y$ }+ A* w4 w  t) K
MODULE_LICENSE("Dual BSD/GPL");
$ T8 ]; ~  X$ a) E, y( FMODULE_AUTHOR("iTOPEET_dz");
) D9 C# q6 \2 a9 B- Wstatic int power(int flag)
6 g( d* {4 ~; T; M; [{: y7 h2 j4 M" h7 P7 i/ ~- [6 i
if(1 == flag){regulator_enable(ov_vdd18_cam_regulator);9 U3 O+ M& H+ F6 }; {6 ~
udelay(10);% |5 H; c+ o" t* V$ }+ u8 z0 ]
regulator_enable(ov_vdd28_cam_regulator);' U" e2 C' R5 `6 p! J
udelay(10);* F/ z8 j2 u8 i% Z4 E
regulator_enable(ov_vdd5m_cam_regulator); //DOVDD DVDD 1.8v# ?! n1 _' L8 \9 _" \
udelay(10);; I! b0 {" J  M; L' m+ {0 d
regulator_enable(ov_vddaf_cam_regulator); //AVDD 2.8v9 |& Y' e) ]9 Y3 i
udelay(10);0 @2 n1 o% B! Z( h( P$ T
}
0 N* P5 R4 E5 B# R& Helse if(0 == flag){+ w( R: o( G1 h7 o
regulator_disable(ov_vdd18_cam_regulator);" t" J" T1 t8 N9 v( p
udelay(10);: |0 D% h) s4 H1 \
regulator_disable(ov_vdd28_cam_regulator);
+ T6 j( b$ S0 M' o7 d; C' |' Kudelay(10);regulator_disable(ov_vdd5m_cam_regulator);5 H% t7 n2 T5 d7 ~# y# V! ^+ d* D8 q
udelay(10);regulator_disable(ov_vddaf_cam_regulator);
9 n. B3 ?1 F% k0 v9 Dudelay(10);
4 z1 c( D' _5 @7 k& r0 ]( M( c; n}
, n; a! Y0 _+ W5 I! Q' mreturn 0 ;+ d! W( M1 ^( D8 z' Q. Y" O
}
, a: E9 z1 S/ V/ @9 t& Wstatic void power_init(void)
" B' X' {) M  l4 t" ]% P/ x4 {% f{! z# i# D+ s" Y/ Y3 Y/ f
int ret;$ ~) F* s6 h3 e  d) A6 V3 j. @! H
ov_vdd18_cam_regulator = regulator_get(NULL, "vdd18_cam");
4 |/ i/ a1 y% F  B  wif (IS_ERR(ov_vdd18_cam_regulator)) {
2 l2 T- l5 S) A1 w; {' X' Kprintk("%s: failed to get %s\n", __func__, "vdd18_cam");
" l* g: q6 P- V6 q6 dret = -ENODEV;" r1 t6 P  V7 ~, `( k4 i/ v/ H
goto err_regulator;}ov_vdd28_cam_regulator = regulator_get(NULL, "vdda28_2m");
( ^& Y4 {+ A. a& x/ w3 h" u: ]if (IS_ERR(ov_vdd28_cam_regulator)) {4 h; x  @* [0 }3 Q, ~: l5 T1 w. `
printk("%s: failed to get %s\n", __func__, "vdda28_2m");
$ I0 T/ f* H; V1 t4 N/ bret = -ENODEV;
* [: F) A* y5 i! y# D4 @! xgoto err_regulator;
$ I# ]+ Y% s$ P( V0 x}+ ^3 E; B6 i  H1 r
ov_vddaf_cam_regulator = regulator_get(NULL, "vdd28_af");# p! x& U) U( u) a! x
if (IS_ERR(ov_vddaf_cam_regulator)) {
" h, V1 j& ?; [. x( j7 n7 M. tprintk("%s: failed to get %s\n", __func__, "vdd28_af");" {: i! i0 D6 T) R. w, @! E
ret = -ENODEV;goto err_regulator;
8 {5 E: ]( g6 v& r# Z3 ~9 f}7 |. }& S% W) m8 ^2 U0 o3 H3 ?; V
ov_vdd5m_cam_regulator = regulator_get(NULL, "vdd28_cam");( z5 h  y  @0 I2 m& u. W. e
if (IS_ERR(ov_vdd5m_cam_regulator)) {) z  o! O" v# }( S9 Q" O
printk("%s: failed to get %s\n", __func__, "vdd28_cam");
+ i. ^0 I) J4 \3 H* K: Zret = -ENODEV;goto err_regulator;" A: e% D, z* R: c
}: `# D2 ]- y" r" t- Q
err_regulator:
; K7 r4 Y: e$ Dregulator_put(ov_vddaf_cam_regulator);) Y* M* S5 h( Z5 B0 [: @6 d
regulator_put(ov_vdd5m_cam_regulator);( }; F# s) c* k; b1 t- A
regulator_put(ov_vdd18_cam_regulator);
' `  u: x" S9 D4 n! W' Bregulator_put(ov_vdd28_cam_regulator);
; q5 q9 S! I8 W4 ]) \+ R( Q}! h% Q( X4 f9 ?+ g/ Q
static int hello_init(void): _7 G% l0 t( ?, {  p( i0 s
{
! q# Q9 ?- A$ k" N; A- qpower_init();! L6 U, G- `! d. e
power(1);3 Z, j& U# H4 x' @' E
printk(KERN_EMERG "Hello World enter!\n");* H/ J  E5 A+ F/ W6 f
return 0;' |6 B$ k- @9 }* T+ S2 D/ w4 v/ Q
}6 h8 m+ t2 v! N
static void hello_exit(void)& b/ x, G: F! z
{
, j3 k7 |/ l$ S  hpower(0);
1 T& [6 g5 {1 @printk(KERN_EMERG "Hello world exit!\n");  V( b4 M3 H- m* ?; b1 I
}1 H9 ^( o' g& Z: ^
module_init(hello_init);
' t9 |: h& A6 W9 _module_exit(hello_exit);
' w- @+ ]1 N1 \6 p: `" |* t* ~
" {' j) o+ J5 W2 GMakefile如下所示。
$ U/ T& s: q2 S" \1 `5 U- L#!/bin/bash
1 q8 u: }$ o, ~1 Cobj-m += power_s5m8767a_test.o
9 z& O& w  M3 q  k. eKDIR := /home/topeet/android4.0/iTop4412_Kernel_3.02 a$ p3 Q. @3 K" Z$ M3 J
PWD ?= $(shell pwd)$ u7 f2 W% j1 w- x
all:+ g. Q% J" R& t
make -C $(KDIR) M=$(PWD) modules
$ E) Z2 y/ h% \0 z! O: Xclean:
0 n8 `' n) ^+ {2 E$ W9 K" s/ S" ^rm -RF *.o modules.order *.ko *mod.c Module.symvers! r- X# i; r2 |8 U
我们加载驱动之后,测量电压大约为3V左右,有压降,卸载驱动之后,电压为0。说明驱动运行成功,如果在自己的项目中,假如需要用到电源控制,也可以参考本例程来实现。

4 h, e# T$ Z6 Z/ a; [+ Q' a
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-8-24 22:04 , Processed in 0.125000 second(s), 27 queries , Gzip On.

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

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

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