|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
N& } J+ Q8 N#include <linux/init.h>
3 S% e) q3 S. j) C#include <linux/module.h>
7 G6 j# i6 ^6 F) o#include <linux/kernel.h>, T9 l5 C/ \! ~1 U( N1 d: j
#include <linux/types.h>) U# E- S( N% x6 U% K8 ^
#include <linux/gpio.h># F3 e* G6 L7 O& T" g+ b# L
#include <linux/leds.h>6 e! q) O/ H6 u8 \6 ~6 p# |
#include <linux/platform_device.h>& O) H }4 F" {0 R m
, z8 y# v8 d7 ~
#include <asm/mach-types.h>2 K. E% W* o- P6 m& ]! m
#include <asm/mach/arch.h>3 O1 X( \0 f5 l( v3 |
#include <mach/da8xx.h>
, w. T, q! [, B: o1 G5 Z#include <mach/mux.h>
# r1 M' n2 I: z% }* z4 g" b# K; T1 k1 ]8 Z
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 G: [2 ^4 q. @2 a: P" Z4 m" _! b
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- m" d/ a) c6 F: h$ G+ v#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
4 f3 Y0 G& b1 X#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
?! }) Q& F) |1 u
+ K* d, Q0 Y) ^& b/* assign the tl som board LED-GPIOs*/9 `. x) J; ~ l h
static const short da850_evm_tl_user_led_pins[] = {
8 K# Z5 H6 n* l y- N8 j! i* i /* These pins are definition at <mach/mux.h> file */
; N% b+ q% [1 u DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% z6 X) l; C! a- m
-16 B# H) ], S. ~) w( |* s r
};
$ j$ s& W) W1 [+ W2 D" f( u( r1 K* V' \
( s" D% \) ~4 A1 G7 S: Z6 }static struct gpio_led da850_evm_tl_leds[] = {: r! p7 C$ j* }
{
$ c$ D, r+ Y7 Q# u0 X1 R" M .active_low = 0,
6 J2 K( G# {' f/ _; T8 ? .gpio = DA850_USER_LED0,
3 F( F; n2 k8 S) F. ]! e/ L" V- @ .name = "user_led0",/ i1 h, j, U- { L3 e0 x# j. m( n
.default_trigger = "default-on",
2 g0 ]4 ^4 `3 @4 m3 T. I6 R },
" s3 X# Q5 k$ w2 P3 g% n {: q9 U9 b; j: ~1 O3 u* o
.active_low = 0,, L* Q( b$ ^2 l7 `' k4 g Y! j/ h
.gpio = DA850_USER_LED1,
) t' d: r3 C0 }8 Z: a& ]$ N .name = "user_led1",
0 A6 l6 r6 o: Z4 h0 q- y9 c .default_trigger = "default-on",
! \7 e8 u: h4 w$ q },
' ^# g. L7 E, t+ B {1 m3 W5 j( u3 G/ p8 f" [, A) @, a
.active_low = 0,' ~7 i3 K- @2 g1 i
.gpio = DA850_USER_LED2,
2 y8 s+ F4 l) A( _+ w# A0 h' Z .name = "user_led2",
5 N0 D" {. V, e# M; I1 M- | .default_trigger = "default-on",! z5 B3 S% ~$ b( w' o! m4 n
}," x$ V$ ^3 j& S- ^ }7 b
{
8 c, @, H }' c6 v .active_low = 0,3 H6 `0 Z5 W) V8 G0 h7 t
.gpio = DA850_USER_LED3,
# B. U9 R/ s& d' N% \ .name = "user_led3",
- V6 b% V7 p, j6 ^2 h' S .default_trigger = "default-on",
/ ?3 g9 v2 [* ? },: ?! B" J6 p' A$ Z
};
2 c) i2 B3 T0 V2 u/ e# l1 r" G5 e) y F* O4 u+ O
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
9 y6 h0 e5 E- [2 U! I .leds = da850_evm_tl_leds," J: Z1 e/ }% b
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),* T ^* O; [7 v% U0 o" | K! E% i
};
% h+ X9 j/ }1 C/ ?3 \9 W
3 k$ D6 x# U3 L' w9 D5 v% Cstatic void led_dev_release(struct device *dev)5 R. I' R" g7 S
{
" ?$ i# J G% V};. g! e9 h, L; @( h* _8 Q) s( [% H
; q- ?. u1 w& y* F1 b1 R. ?7 | J
static struct platform_device da850_evm_tl_leds_device = {' z6 L" R4 b- V' x" m( F! }
.name = "leds-gpio",9 }6 N3 m: b1 z2 s# J+ k
.id = 1,, r K: y. `- A
.dev = {
0 L/ K& r- ~2 P. t$ \- F, i .platform_data = &da850_evm_tl_leds_pdata,7 \3 j( h1 S8 a( `/ P% ~: @1 z
.release = led_dev_release,
7 t6 z/ G ]& F! M7 N2 o }' t& y$ T/ Q; M) R3 c
};' n. p! k8 W7 A$ E; ?4 V/ Z
0 H# U# ?1 h6 N( T" g( r! b4 p
static int __init led_platform_init(void)
1 _% e9 ~8 [7 S) N: f# Z* [{
( `' ^* x3 W+ N) _3 T int ret;- P' l2 x( w! W [7 J, z: _: Q% z' V
#if 03 C9 P$ f; @% u' c" n0 n
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);" Z/ G4 I7 ]& f) q9 {: h+ f
if (ret); y& |7 r: B/ s% R1 q
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
% X8 R5 Z' d$ Y7 p" F5 d* ~; P "%d\n", ret);& d' t; ?* s7 r4 ]/ \8 G2 ]
#endif
7 W0 [0 ?% s* s( g0 O( @ ret = platform_device_register(&da850_evm_tl_leds_device);
' G& {# h& m+ V9 { if (ret)
: {( e' i" a. j! p pr_warning("Could not register som GPIO expander LEDS");
* e+ {% G) V" l; i9 z6 s4 z) T else
. @) X% \) Z4 c- y printk(KERN_INFO "LED register sucessful!\n");
2 A3 i! n6 q- Y. Z+ L2 a7 Q7 A4 `1 Z6 O% c/ c' `, f; R% M
return ret;
6 X3 V8 R. j, F7 |2 A% a" }; k}
5 \8 b- u* D* C. V
7 U9 f" g* e# L+ P7 K# q8 zstatic void __exit led_platform_exit(void)
/ C/ [1 }" j% v{5 \! u8 e# x$ F
platform_device_unregister(&da850_evm_tl_leds_device);
" U; }& _0 Z1 n& L5 k) j9 {% K, a p1 O* u# S9 @
printk(KERN_INFO "LED unregister!\n");
) [1 S7 O2 L5 z9 [3 \}% f* G; U. D( L2 U; H: R/ P# l
* D8 f! c) d& d
module_init(led_platform_init);
% }3 w5 ~0 M; ~9 Imodule_exit(led_platform_exit);2 z- O) w/ q* r W6 N
! m+ `- h' M1 U6 F" b6 {! q7 Z4 `
MODULE_DESCRIPTION("Led platform driver");3 j( Q$ ?6 n7 N% W( F c
MODULE_AUTHOR("Tronlong");
4 g) ~. Y) v3 o5 e* KMODULE_LICENSE("GPL");! w& S6 n0 g! I+ [
4 p7 P! c4 }2 I1 j: V+ m |
|