|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
0 p5 b J( }* ]) y0 p" C+ r1 ~" |#include <linux/init.h>( @( U. }. ~1 m5 j- n. q! e7 b
#include <linux/module.h>4 |2 _; ?2 E6 U. z1 y0 c/ {5 h
#include <linux/kernel.h>: N/ B4 f; Z7 e0 e$ {+ }1 S+ [
#include <linux/types.h>6 p2 r0 n" D* e) J
#include <linux/gpio.h>7 O- Y8 x$ @* I
#include <linux/leds.h>. ^- l4 I4 f% V
#include <linux/platform_device.h>
8 a3 O' h8 Y6 y* g3 R" T' k7 L _4 A# t" u0 F: _# X; Q4 E- b/ ?
#include <asm/mach-types.h>2 D) q' l6 t8 S1 i; V
#include <asm/mach/arch.h>1 t( N& M8 l( s
#include <mach/da8xx.h>
! g' |/ `& [+ n# n5 `#include <mach/mux.h>0 b/ |8 I! |4 e c9 q9 W7 U
$ y5 [" H+ l ~$ [& D/ @#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
6 B3 @# e3 B6 \) L3 U, h5 p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
; R6 L* E) M0 t1 P" q1 H7 a#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)9 A; b9 W b5 ^) n/ q% S+ h" N
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
& C4 y E+ z7 c0 i9 l* p
. ?, w$ U" k! M( {7 j/* assign the tl som board LED-GPIOs*/$ Z7 s+ ^& e5 v: D2 Z2 `* ]+ c4 @% ]
static const short da850_evm_tl_user_led_pins[] = {* O6 M9 w, M+ C: u5 Q+ q
/* These pins are definition at <mach/mux.h> file */* l! K2 l, w. P& X3 b
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
4 d. ^$ X6 \, \4 ?3 ?7 F8 e -11 I/ k( p) w9 ?! Q3 M
};
$ z1 y* n% Y) y: P( C
, m/ B- y+ |* Q$ l& r. D& jstatic struct gpio_led da850_evm_tl_leds[] = {7 S( k# [! H# C' L% }2 H# L
{
$ B, b* K( s/ ]7 s J; g .active_low = 0,
3 v! F' z" G$ J .gpio = DA850_USER_LED0,3 L$ {3 j5 p9 }& X" B% z* r
.name = "user_led0",( n, k" t, R9 S5 m
.default_trigger = "default-on",6 m/ K* i7 }* T& z
},3 V5 n c& W5 q! V. \! I
{
3 x: d' m% c- T .active_low = 0,
. D6 i8 r9 R6 V6 a .gpio = DA850_USER_LED1,: ?1 P \' j2 s
.name = "user_led1",
4 x- e* k0 V" H; u .default_trigger = "default-on",
9 ~6 t# m O! m },& J; z) Y) s6 w. G: A; j, |" ^
{
+ I" l& X% Q% M9 M .active_low = 0,
/ i% s1 M+ m4 A1 Z7 U .gpio = DA850_USER_LED2,+ N' h( Y8 ?- E3 ?) Y
.name = "user_led2",
- h0 U: B9 \: h. }0 m8 J$ h .default_trigger = "default-on",. X5 I. @% |9 S8 v
},& w$ F- F6 a8 C5 H
{
5 P* V* m2 Y5 i6 Z; d- [ .active_low = 0,/ J8 W1 u. e8 L4 A
.gpio = DA850_USER_LED3,1 B; M( d0 S% M4 Y, U2 d; T
.name = "user_led3",
. t$ h# c- J# _3 `# F' n- E9 h .default_trigger = "default-on",
3 r8 t3 M6 ]/ m7 Q },7 D% i5 u1 g" M/ M. c b3 c
};
/ @ e0 {: E( w3 k s# P1 l; J6 s* O! W& y' V/ y' O- m
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 o. m' _. C8 _) m
.leds = da850_evm_tl_leds,
# m9 B& n& M& L5 N) c% q; A* Q n .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
$ J% s9 t. W \' g8 x};# N4 U; |" h7 l* z5 y7 Q- @
" J: L: l; m0 u m/ istatic void led_dev_release(struct device *dev)
% Y1 O$ t( ]3 m; J' a k{
4 B9 p/ X4 I0 T% X};5 \. ^+ M8 F5 ~! O' r& R
( r/ E8 R$ g$ S2 Z! x5 _
static struct platform_device da850_evm_tl_leds_device = {
8 W: J: B) c: d .name = "leds-gpio",7 ?3 n, Y* `8 F# w9 L
.id = 1,
9 p" N2 G! D0 k+ ]* n) n .dev = {7 I" E$ v* h% f4 g" D
.platform_data = &da850_evm_tl_leds_pdata,
1 ~5 `' E) ^& z: W: b6 J5 D4 f4 [ .release = led_dev_release,2 [0 W! ?% q& O+ y7 \! Z
}
9 e: s2 j& C P7 Z L};
! M/ o/ |* h8 _% B+ h$ ~9 n; }9 b) _$ L# b2 `% w# q8 }6 i
static int __init led_platform_init(void)
9 h) }8 r: I3 w$ D o; w{
9 d; ?6 ]0 k- P; `0 J" u$ D. p int ret;
* g; w7 r, q r2 q$ t#if 0
F6 k6 n z4 C& ?. A. y0 E ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
! A+ K" @7 _% i, d% f if (ret)
, L8 v; l7 U) N+ V$ e% n pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
/ o- _% i% J* F8 d b "%d\n", ret);8 l" L: C3 I* d D
#endif8 @/ u$ N" E' D. G# x0 p
ret = platform_device_register(&da850_evm_tl_leds_device); p) j D2 v% W$ K
if (ret)
$ M4 V* U* r+ R# {0 d pr_warning("Could not register som GPIO expander LEDS");1 V P/ S/ z6 P) [0 y; N
else/ ~- @: n: s& E6 j# M. M! H
printk(KERN_INFO "LED register sucessful!\n"); N" u* |$ C7 h2 u) e8 J! ~9 b
* x1 Y% B- t" ` return ret;! B8 ]& E. n+ G* f( s& Y
}
% V. r& }; z7 t! [% a( |# d
8 j& T- M* J U I9 s% fstatic void __exit led_platform_exit(void)/ y2 h, _0 o! ~# d5 r0 ^
{
$ K8 g0 _& X( G' U) i( B- h6 j platform_device_unregister(&da850_evm_tl_leds_device);4 I* e3 k0 a8 w
0 n/ C1 ~2 w1 Y' J9 P4 y: l1 d
printk(KERN_INFO "LED unregister!\n");5 o" r! X; r* p R d0 e
}7 O+ F9 K$ S& N9 W# [0 K! o- D' m
7 \9 }! @% S, E4 ~4 Dmodule_init(led_platform_init);5 m# O- \- q* T& m
module_exit(led_platform_exit);. L9 u) x) \" _. k8 j7 h" I
+ g! D, O- i2 U: f
MODULE_DESCRIPTION("Led platform driver");
( g. @. n) s L! Q2 ZMODULE_AUTHOR("Tronlong");
6 w" X% D3 q% D1 p4 l2 u" k$ TMODULE_LICENSE("GPL");
' H* n9 H' j: v2 z4 c/ X" D5 T3 v) _+ T% a1 ]; d/ H, L
|
|