|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
. U7 Z" E3 b- v, r$ _: e- U# F; E#include <linux/init.h>3 ?% Y) I5 ?) ], U
#include <linux/module.h>; R+ i" v( [, z% h
#include <linux/kernel.h>- W5 K+ e! U+ x3 b# V
#include <linux/types.h>
" f( s' K7 l2 B f) t4 @- {; }#include <linux/gpio.h>
9 c* Z# [+ a' t, _- h. H#include <linux/leds.h>! N1 V8 q/ b. M4 G. x
#include <linux/platform_device.h># F$ b. o7 p" x1 g0 [
0 h8 v# \3 [. ~, k#include <asm/mach-types.h>! ^! y2 H5 s4 S
#include <asm/mach/arch.h>. G: w. n; r& d# m- m- X7 O1 N
#include <mach/da8xx.h>0 a E* ?0 r1 @: n
#include <mach/mux.h>
6 Z: `" a3 y# [5 F+ u5 B# I0 A# U: d- m; e# ?' n5 G
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
5 h) X, t# I: `; j#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)0 }3 P0 w3 K+ O8 k$ c/ P/ c! U
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
) G/ {. j, u! H6 [9 z6 g0 P#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
' C. m9 E/ e0 h7 T8 f7 L
1 ~6 s3 T, Q4 q4 ]- N/* assign the tl som board LED-GPIOs*/
1 z. B) y. |+ @static const short da850_evm_tl_user_led_pins[] = {9 \, i% y$ N7 C$ U% f* f& U% S2 U f
/* These pins are definition at <mach/mux.h> file */( w5 x" k! X7 ?
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,0 W5 ^' H& {' Z% P3 z h# S8 g
-1; g5 H- C k2 G+ y
};
/ G) d9 G, J2 R/ J- {
9 k, S# s$ [, o# C; c+ i5 Qstatic struct gpio_led da850_evm_tl_leds[] = {) v/ M- }6 K' n1 ~6 K
{
) `# f8 c" C" ~ .active_low = 0,6 |8 K1 H q$ C. z
.gpio = DA850_USER_LED0,
' q6 O# A- ~$ v .name = "user_led0",
! [' e, }3 n! z5 R .default_trigger = "default-on",) m6 }3 T4 q( M9 v) [' G
},# D9 F( F+ Z7 x6 r1 i- U& W7 t$ _
{' O4 a4 V( i) x% O. n
.active_low = 0,7 J) W3 N0 [ P" s/ W1 q
.gpio = DA850_USER_LED1,! a" q1 Y) e, I' M+ z" O0 H
.name = "user_led1",
) R2 _" z$ w5 a5 g: L/ I& M .default_trigger = "default-on",) s# V/ T& @& Q
},
) Z/ A. O. @0 d& \& e8 Y$ ^ {+ ~# u- l1 T" |; [
.active_low = 0,+ g* @1 \6 Z- }7 k: w
.gpio = DA850_USER_LED2,
8 c9 n/ n: k3 A1 B .name = "user_led2",% z& y4 U, y$ t" z$ y% K
.default_trigger = "default-on",4 q' X' ~( a% U- ^. i7 E+ t" u
},' z; e* i+ q$ _1 {0 P+ H) g
{4 }: k, i/ N3 N2 f$ W& ` Q" r& C7 ^ s
.active_low = 0,
. [# c7 |$ w Y7 c U) v2 W .gpio = DA850_USER_LED3," F! i5 t7 t1 A1 l& z b2 i
.name = "user_led3",: c W( N4 b$ \; S* T. z) M
.default_trigger = "default-on",
! t t2 M. I+ I1 Y- J },8 b' u7 j6 P0 w
};: u$ |( h, b, x2 z% ^
+ H; n2 {0 n. u2 q( X4 f+ S* M
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* N9 r! e: O1 a/ ]
.leds = da850_evm_tl_leds,
5 G* J Z/ e8 }' g: k4 g9 C, \) k .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
) S) [) K @6 B* T! o' p& f};
; T0 c: `3 x; v3 x6 s
+ F% r5 V9 H- ]. p4 Lstatic void led_dev_release(struct device *dev)) D5 R5 ~* q# P/ S" D4 I) a* J
{
/ f; n6 U0 f m% e};
/ Y; J3 t3 x7 i6 x9 v8 r3 o0 s6 z2 f6 o0 O+ k# l, Q! @. C
static struct platform_device da850_evm_tl_leds_device = {
4 d5 C) A0 _+ `. I/ X7 v .name = "leds-gpio",
: U/ _& M' j$ B5 b* m# v- J' H .id = 1,
6 `8 C, s- B: t .dev = {6 s! Z& @. N8 k6 x" i- L: x4 g
.platform_data = &da850_evm_tl_leds_pdata,6 b' \6 k) s2 r+ ]$ ^. K" H
.release = led_dev_release,
7 Q( k! c' l. [! v: P1 J }
8 S" k2 @* _" F5 z4 { U- Q};6 u( c7 w } U6 M, Y
/ J$ S- H. a- Mstatic int __init led_platform_init(void)
# ^* j+ P4 F( P" E$ h# z: ]1 C{
+ C% k% a1 s3 u! k int ret;% n! V; H$ p+ e
#if 05 B' X& c1 O! C
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);* K; n5 i9 H1 R5 _
if (ret)
3 s( Y, {% d4 e4 q8 L, @4 b pr_warning("da850_evm_tl_leds_init : User LED mux failed :"; n. m0 U! N$ ?' l# w# q V* K4 B, ^/ Z
"%d\n", ret);( K: m4 u4 }1 G2 X
#endif7 e4 b: U* v% e8 A
ret = platform_device_register(&da850_evm_tl_leds_device);3 I& J6 i7 E: ~2 p
if (ret)
$ ^ ?; ~4 M& s& e3 F pr_warning("Could not register som GPIO expander LEDS");! |& U6 E$ V4 z7 f4 L
else* j8 J3 z' i; `# V5 C4 Z( [% r
printk(KERN_INFO "LED register sucessful!\n");' q9 E* D; d0 r& ?! l$ y( i
' y' I& ^3 M# g
return ret;
/ V2 d/ C* F) c0 N" M}) z; J% I( [8 x G* H4 t: v
( `" R" c. _1 h0 |
static void __exit led_platform_exit(void)
/ }5 q6 r1 D0 ^3 q/ L: B- y# c{
2 o( c# N' M( n platform_device_unregister(&da850_evm_tl_leds_device);0 I* w3 Z8 ~% {$ d$ @- R
& s, @! V# a5 Q2 s, o printk(KERN_INFO "LED unregister!\n");
+ }) D% z5 _. d7 N9 p( b4 y9 e}8 G! T+ _& C- G& D" i
9 `- f6 _3 k/ I
module_init(led_platform_init);
1 x: }1 p0 j% @# K) m! smodule_exit(led_platform_exit);
, T& y; H" o* H5 J3 b: z
# \$ U: G3 o+ e7 x* pMODULE_DESCRIPTION("Led platform driver");
+ G0 _3 g- M7 F- _$ V5 UMODULE_AUTHOR("Tronlong");$ Z7 K( ?9 y5 {
MODULE_LICENSE("GPL");
* N$ S# `9 j% {& z0 w! {1 r$ H# `' a7 Q# A& V- n
|
|