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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
这周技术支持的时候遇到一个小伙伴,想把底板上2.8v的输出修改为3.3v,但是不知道要从哪入手,所以,法师推文的素材就又有了~~~这位小伙伴看到记得给点个赞呐~
0 Z5 h" Q, Q9 `  O# _S5M8767电源管理芯片是三星专门针对4412研发的,S5M8767提供9路BUCK和28路LDO输出,每路电压的大小可以通过软件进行设置。这里我们以迅为-4412精英底板VDD28_AF,VDD28_CAM这俩路为例。
, p- ]. Q. [* D# U3 [原理图分析
+ ^3 K0 b# W# q: p9 D1 P! A在底板原理图中找到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! `/ j! L, Z. b4 ^% _
然后我们找到对应ldo20和ldo21的代码,如下图所示:
我们将红框的中的代码2800000修改为3950000,红框函数中的第一个参数表示8767电源芯片的第20路,第三个参数表示输出最低电压,第四个参数表示输出最高电压。
     最后我们还要在menuconfig里面将5640的驱动去掉。这样我们软件的配置就完成了。
测试
     测试代码如下:
#include <linux/init.h>
5 c7 ]6 z# I$ d( H) P: h/ u. K. _#include <linux/module.h>% ]8 i, p, K! l8 f' \
#include <linux/i2c.h>
0 B: ^6 l+ I2 K7 J#include <linux/platform_device.h>
9 @: i; ~  k5 o- L#include <linux/delay.h>
+ }2 ^  N- N4 v! j6 T% f5 M#include <linux/regulator/consumer.h>
+ Y( i( r2 \# M#include <mach/gpio.h>
0 K$ h: p5 l1 B- P% `0 O  ^0 P1 x4 ?; t#include <plat/gpio-cfg.h>
% ^8 k& Y( r: J: i5 H; B0 Y7 O#include <mach/regs-gpio.h>
! D9 L& o! X& ?# X; F#include <mach/regs-clock.h>5 w3 u  R* O8 m8 H
#include <linux/fs.h>3 d( J' R; u& b' x
#include <linux/err.h>1 X. _& L; A& u! {
struct regulator *ov_vddaf_cam_regulator = NULL;
7 ?2 ]9 ^% V$ F3 P! Bstruct regulator *ov_vdd5m_cam_regulator = NULL;4 c/ y6 s1 U- x; a6 s9 @- [
struct regulator *ov_vdd18_cam_regulator = NULL;
- M$ s, A- V. R; h& u, Vstruct regulator *ov_vdd28_cam_regulator = NULL;) z) Y: [9 }, c; s" H$ z
MODULE_LICENSE("Dual BSD/GPL");3 E: b' \! h1 b( A
MODULE_AUTHOR("iTOPEET_dz");7 m8 d4 q' ~7 ^! m! ^
static int power(int flag)* n; M( @: _! [2 N" E7 f
{
, T3 d' ?5 d! ^/ E  k4 tif(1 == flag){regulator_enable(ov_vdd18_cam_regulator);
" T0 n% z5 t5 Fudelay(10);
: z: z# @1 m( Z: ^( C9 M" ?9 gregulator_enable(ov_vdd28_cam_regulator);* w0 U  i3 v2 m7 }
udelay(10);* S$ }% U8 F6 c! z
regulator_enable(ov_vdd5m_cam_regulator); //DOVDD DVDD 1.8v) E0 R0 I* v# w
udelay(10);
; ^4 K/ k9 t/ l; z1 k* M! {2 C( ~regulator_enable(ov_vddaf_cam_regulator); //AVDD 2.8v
3 P8 @' O" H) L% r# T) ]udelay(10);
6 [3 c: I3 h5 c2 O9 C; T}
1 J* I) x2 t$ Uelse if(0 == flag){/ Y- v7 k9 W* g! k: m
regulator_disable(ov_vdd18_cam_regulator);
9 {: c3 ^5 O! `" J& Judelay(10);/ u, T# a, G9 {
regulator_disable(ov_vdd28_cam_regulator);/ d, a9 o& h+ `7 C: b& n0 k/ [
udelay(10);regulator_disable(ov_vdd5m_cam_regulator);+ k+ |; s3 \+ R1 i; @; I$ C/ V2 c, C
udelay(10);regulator_disable(ov_vddaf_cam_regulator);- e+ |+ I# p/ [! k" K% s8 V1 S1 p
udelay(10);$ L6 c2 H9 w. k( J* x: J
}- C3 m0 z7 \, X6 Q) g! _1 C
return 0 ;! N2 s9 Q: S4 p& `2 I
}
4 V, f* h; [8 ]& ^static void power_init(void)
' T0 v8 u7 \* j$ t" A; T! Q{
. F1 p' ?# H" x' c, m- r$ nint ret;8 s# C5 b' z8 W5 W. ~) w* m8 }
ov_vdd18_cam_regulator = regulator_get(NULL, "vdd18_cam");5 b) F) `3 b8 g- K$ Y& X$ n
if (IS_ERR(ov_vdd18_cam_regulator)) {
3 p5 B" d$ R+ U5 Hprintk("%s: failed to get %s\n", __func__, "vdd18_cam");7 F" O+ u: a) {) ~/ w! g
ret = -ENODEV;  i4 |4 Y% S/ Q$ T) W
goto err_regulator;}ov_vdd28_cam_regulator = regulator_get(NULL, "vdda28_2m");
1 y7 `2 q# |' c5 U* w: y4 U- Zif (IS_ERR(ov_vdd28_cam_regulator)) {
/ ^2 y" b; [6 v5 U" x3 v! kprintk("%s: failed to get %s\n", __func__, "vdda28_2m");
4 p3 M$ ~+ ?. f5 q4 cret = -ENODEV;
2 y( c  ]7 @2 b/ dgoto err_regulator;4 e% z+ }* {3 B0 \0 E
}
: l) H/ o' C+ l( ?ov_vddaf_cam_regulator = regulator_get(NULL, "vdd28_af");
8 s3 F. d; I& j. b1 }if (IS_ERR(ov_vddaf_cam_regulator)) {
7 i4 t* V* Y4 J2 t' fprintk("%s: failed to get %s\n", __func__, "vdd28_af");+ S: H, b- q& \
ret = -ENODEV;goto err_regulator;; R& s# p4 Q2 S' u2 m
}" y+ t6 |; M$ c; ~& |5 N! J( L
ov_vdd5m_cam_regulator = regulator_get(NULL, "vdd28_cam");
( g! A7 a/ ~: k: H' @, H/ _if (IS_ERR(ov_vdd5m_cam_regulator)) {4 S/ r8 `2 H3 P  s
printk("%s: failed to get %s\n", __func__, "vdd28_cam");. Y# G/ m2 {0 L( z* _4 G1 f
ret = -ENODEV;goto err_regulator;* t# `, I  V2 t4 _
}
; a% V0 a2 d8 ?err_regulator:6 w! L8 ^9 u% g# W6 ]1 o6 h/ d
regulator_put(ov_vddaf_cam_regulator);) ~: F  f3 G1 P! B
regulator_put(ov_vdd5m_cam_regulator);
' P$ o1 H& |2 r& Q3 i" N9 P3 Nregulator_put(ov_vdd18_cam_regulator);6 s* ^% g7 [  a& s) a
regulator_put(ov_vdd28_cam_regulator);
6 k0 a! c8 z' U; f* q, _}" v7 Q( o% d# V6 m3 J" R
static int hello_init(void)
6 f. G( m: W; f' V6 |5 t, v1 m{9 c2 ]0 g% m- v; p# E" K2 u
power_init();
( @& T* D  G, g) \power(1);7 r) m8 `/ P- v3 v( \
printk(KERN_EMERG "Hello World enter!\n");  L; U6 j+ X# V! y4 t7 p$ k& g
return 0;
! m7 r3 j7 c  B% u9 s}  @7 Z4 i- o6 Z8 }
static void hello_exit(void)
' p/ k( R/ S6 F9 h! I. h& W) p8 o" U# T{
4 |: Y8 F. D" m4 W, h7 |6 Cpower(0);! y+ C5 w7 ^  y) e6 v  u0 v" P  M" f2 s
printk(KERN_EMERG "Hello world exit!\n");! b# T0 [5 h1 U& S. Y
}6 b* S* l0 Y" L
module_init(hello_init);
) n' y# z( P7 H. ymodule_exit(hello_exit);
6 H0 a0 f1 z3 j$ S0 A
( ?& r7 b4 W- T( e5 ?8 AMakefile如下所示。
% Y* H/ n% n5 v- T9 h6 O' m( D#!/bin/bash
' U( X- n/ R4 @8 r9 [7 Z" n0 t& Zobj-m += power_s5m8767a_test.o# B: N( b6 Z+ W) c
KDIR := /home/topeet/android4.0/iTop4412_Kernel_3.0
2 c! o1 l5 M! ^9 yPWD ?= $(shell pwd)
* T4 w; K3 u( _- Aall:
4 X. ]) N, E, Omake -C $(KDIR) M=$(PWD) modules) {) h* \2 b$ E! p( }; y
clean:
/ n* {3 M' V$ Jrm -RF *.o modules.order *.ko *mod.c Module.symvers5 G% V, f( M0 G; f
我们加载驱动之后,测量电压大约为3V左右,有压降,卸载驱动之后,电压为0。说明驱动运行成功,如果在自己的项目中,假如需要用到电源控制,也可以参考本例程来实现。
2 u' D, r9 _8 h+ s5 C
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-11-25 12:48 , Processed in 0.171875 second(s), 27 queries , Gzip On.

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

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

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