|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. y9 o2 z9 ?' x' ~/ j& G
#include <linux/init.h>
; h7 S4 e% \9 y" w1 J* V) Q#include <linux/module.h> p2 r, }! A" h P% B5 W6 J
#include <linux/kernel.h>5 M0 I+ Y9 ~" ~4 C
#include <linux/types.h>
9 f9 d4 q2 ^3 {#include <linux/gpio.h>- u& ~2 D! f! m0 w% ]' e
#include <linux/leds.h>7 H' d! r9 o8 H+ B/ g
#include <linux/platform_device.h>
' o- m& H. Q+ x) H0 [+ I
: `; h5 k" {3 w! g( s# N2 N#include <asm/mach-types.h>9 j: G/ q5 ?9 |/ O% W0 G* s& X
#include <asm/mach/arch.h>
2 B; H- C+ h/ e+ o6 q#include <mach/da8xx.h>; u t3 y' }* [: W/ S
#include <mach/mux.h>- _, Q7 T$ g& O' K, n( h6 G$ P
( p1 t0 P% T+ X' n a
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)6 |9 I/ q: s; |' Q& x8 |# M2 Z! g
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
# h, I+ }% E' Y! B, T; @#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
! ^/ H M* z& o1 J: \#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
/ J O4 e4 W' X0 y5 h+ ]+ O0 ?9 q3 g/ a7 |1 k; G( N
/* assign the tl som board LED-GPIOs*/0 Y& @6 C9 ^9 ?$ a3 p
static const short da850_evm_tl_user_led_pins[] = {
- N4 [' p; J" U3 J$ M) X# @- y /* These pins are definition at <mach/mux.h> file */
5 S2 E5 {$ v# C* {5 l6 P/ s DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
' ]5 L% o1 A2 O; w1 F; C6 } -1
, E$ d7 ]3 t. [8 m};' d$ O- Y+ S, _9 i. ?
: e9 m+ c3 E; A; c9 Q! b. E0 istatic struct gpio_led da850_evm_tl_leds[] = {. s/ T; I [. ?* ]# Y
{7 h% e* e4 [! {/ R, S; a3 r
.active_low = 0,
2 x6 V8 K8 E, ` .gpio = DA850_USER_LED0," J6 C% s/ ?4 q8 |) `
.name = "user_led0",
5 B3 B, }0 d0 |6 S+ I& S .default_trigger = "default-on",
* m7 h5 Y O- q! @ },
+ c" ?! }8 Y! p1 `3 z {
; q# c! z# }& z1 Q* D% y7 _5 U .active_low = 0,+ |- P. e o7 r* F$ F
.gpio = DA850_USER_LED1,( _; B3 D8 V H8 G3 u. J& U
.name = "user_led1",
9 z1 ?/ X. s# U% R .default_trigger = "default-on",
& f$ h* J9 \" ~5 O/ q8 E# s' y },
$ ]1 r+ Z2 g9 Q/ z {
! l1 e$ x5 ]- I8 y( P2 L .active_low = 0,9 _* R$ ^; n$ m" Y" H" e8 q
.gpio = DA850_USER_LED2,
! A' v; g9 K0 s% m! l4 T; R, U( x .name = "user_led2",
# Z" V7 i4 i7 [1 x .default_trigger = "default-on",( g) u1 s* X& Q% |- d5 M
},
4 F+ }+ _& U& A2 b {
7 O* ^9 ?5 |9 e) o- U% b; `0 y# \ .active_low = 0,2 b9 c' {2 }) [8 b3 u
.gpio = DA850_USER_LED3,
$ F' a3 H& f& { H# i .name = "user_led3",: o- G! O4 l- T( ^" c
.default_trigger = "default-on",
/ ^% x' f: `7 T! O0 j },
# L( [; d& P. @};- C: w t1 Y, ?- \
2 t% s* E; H- U9 t
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {4 q; g. X$ q! t2 O
.leds = da850_evm_tl_leds,, A6 z: h2 ~2 U/ Y
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
5 r$ S% D# ~0 u};4 n6 ` c5 r) h
% ~" X) ^4 c1 E' c9 Q' [static void led_dev_release(struct device *dev)3 X0 o! G: ?2 q8 e; w
{
+ z r8 e- y; |1 N7 o4 U& T) k% l# }};5 M [: Z2 I2 ?- F5 E" }. |, U1 D, A' ]
, p" m) G0 D3 M
static struct platform_device da850_evm_tl_leds_device = {: A/ z% o1 N: n) \: A% R% i
.name = "leds-gpio",
1 O% k E3 N# d8 {/ k .id = 1,
, s" T/ ~8 e* N+ j, i. z .dev = {
* j' p' |, ?; }+ x, ?5 I1 c' d6 g .platform_data = &da850_evm_tl_leds_pdata,; S7 ?$ w+ l8 y& I6 x2 t, ?' b
.release = led_dev_release,
* L! C' I1 P2 L" C. K }
2 N$ B; _+ o, V) F1 i9 R$ Q3 f/ q};
" e5 ^; Z5 ?( ?; E5 d) q3 u6 y2 Q% _
# h4 [+ T% K0 G: u" y# P) e, \static int __init led_platform_init(void)
5 m8 |7 [1 n5 v$ `% z{/ ?9 _7 R& E2 y0 ~1 c3 S
int ret;4 O) d3 y% Y2 \% D2 r
#if 0
4 [. C& |9 J" i$ W ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);4 i. J( e! Y$ J5 w) z
if (ret)
1 K& h" {3 h9 r+ W pr_warning("da850_evm_tl_leds_init : User LED mux failed :"" _$ V- H3 u( f: }) k. w- W
"%d\n", ret);' x. e0 U" [( u0 \! y
#endif7 c' {3 }; e6 }
ret = platform_device_register(&da850_evm_tl_leds_device);+ O3 i( x& e. t" ?3 R/ K
if (ret)
$ ~& H- m5 L' x# A( O4 y" K: h pr_warning("Could not register som GPIO expander LEDS");- f% d7 l: h6 d* B; z3 y; r- a
else( Q. a2 l: K* j
printk(KERN_INFO "LED register sucessful!\n");
y/ G( ?9 u& N! d- a
o2 P9 F4 m0 z2 g5 z0 U return ret;' b0 u. o- c6 q# _, W# B8 t
}
$ Y8 V4 I9 p$ h- {
8 |3 [) u4 _3 l2 B# O0 N {static void __exit led_platform_exit(void)+ I W {. L( R% B
{' d3 l' S7 M ^" s
platform_device_unregister(&da850_evm_tl_leds_device);
' M) S# B) v# x9 v. A# M) B& Q2 n8 c+ D6 @/ M5 Y5 \
printk(KERN_INFO "LED unregister!\n");
% F9 c) d' ~3 ?7 z}
. l- u3 P- }" D% G3 Q
, q1 ?+ y' W" c- ^1 I3 s4 Jmodule_init(led_platform_init);, G- Q3 s! N: J7 o/ g3 {4 L
module_exit(led_platform_exit);$ h5 @' n2 K# I( T; b7 l
! C8 m6 P9 }" h! Y8 N$ H, EMODULE_DESCRIPTION("Led platform driver");9 N; Z4 c$ t# o+ q
MODULE_AUTHOR("Tronlong");
. p# f$ ?$ u5 g6 f2 A& gMODULE_LICENSE("GPL");) Y1 U$ D2 R& l8 Y; V% g ^8 U& h
! p' ]& }6 Y' y1 y9 e; g1 o0 z. j |
|