|
|
求大神给下面的程序做注解,请稍详细些,谢谢。. K+ E* {+ a/ i7 ]5 b
#include <linux/init.h>
: M; r/ v* {9 t: Z5 G7 L4 l#include <linux/module.h>. Q+ @ }/ w% L( b" `
#include <linux/kernel.h>
8 G$ R: _8 U6 r* I# D& j#include <linux/types.h>
% X4 Z+ ` M# e#include <linux/gpio.h> w1 k ^) {' ~* K2 `5 `6 o- V
#include <linux/leds.h>
8 H$ @, {. k6 t: ?#include <linux/platform_device.h>; t* H& ^! Q' H
2 }7 O9 h7 @3 k#include <asm/mach-types.h>
% n2 F4 X8 w7 e7 \#include <asm/mach/arch.h>+ n D) e& j2 `$ v6 v6 a4 i
#include <mach/da8xx.h>
, N) X5 n- Y5 ?0 r$ b5 U#include <mach/mux.h>2 U# Z9 ], L5 M; U
" z$ B( x& g( ~: o9 K& V. @1 a#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 h+ f+ `+ ?4 ~* [) F/ h1 L( u#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
& Z: u0 ?* W0 [: r' f#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
, c7 C( W4 I( Q/ ~% X' J#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
, }# t! q9 r4 S3 `. Y
, ~1 d& v( t6 ?3 l) R/* assign the tl som board LED-GPIOs*/
6 ~) F! c2 e' T/ _" Istatic const short da850_evm_tl_user_led_pins[] = {5 P1 t0 e/ ^8 v) t! s, ^
/* These pins are definition at <mach/mux.h> file */: m8 C/ k( Q. E1 H$ x" `8 B0 H
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
* C6 ]0 Y. p2 ]7 U- ]6 H' y -1
$ \6 F' y6 ?) U+ i' ]! C};
8 ?3 Y: u. A" f9 D* i! n( ^
# Q8 p& F7 G. R2 j# ]static struct gpio_led da850_evm_tl_leds[] = {
1 F. Y/ |& V4 p {
/ K" q7 W8 ]& J- ~) F .active_low = 0,: Z: ]$ @- h j6 i2 T
.gpio = DA850_USER_LED0,
/ L1 H6 f" ~, N! b. ~1 s .name = "user_led0",2 b0 L+ K3 U& t3 B x
.default_trigger = "default-on",
* V, e& X. N4 K0 p$ ~* s },
" L; f: ]: B* E% t b6 ?% Z* C {
+ Y% z+ ~8 m4 Z+ v; _ .active_low = 0,$ h# S4 B0 b# z/ m
.gpio = DA850_USER_LED1,7 y; X; a; b7 d6 Z* I& O
.name = "user_led1",
) I( r8 c0 N; E, ~) y" B .default_trigger = "default-on",
* Q8 H- ~5 P# ^) A; U6 R8 {+ h },' ^5 L: W8 C+ v+ v% Z
{
, M- @, k2 m' M d .active_low = 0,4 Y3 B) o% r, ?8 q! R
.gpio = DA850_USER_LED2,
l$ ?( W2 h, S8 @+ i4 d% s .name = "user_led2"," }. B# x5 x; E1 s4 b! J
.default_trigger = "default-on",
9 F5 N3 X' `6 y& x },( D6 P* d& B8 A4 E" `" h6 V
{
7 J" k+ z- t, C3 ^: S6 N9 j6 q .active_low = 0,9 t/ H2 x0 g, J+ j" C5 ]
.gpio = DA850_USER_LED3,& f2 q! ?/ W7 A) d" \ f0 V1 h# V
.name = "user_led3",: ^9 `/ L& {. `% U0 h- Y5 l" V. i& [ p
.default_trigger = "default-on",
; S9 T' ~6 K6 Z6 J* X },
. R9 t* S8 w$ B};
- v0 b/ w* Z, s3 q
( X$ H! m. ~5 ^static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {! E) t5 C- r6 h5 q1 h4 C/ B
.leds = da850_evm_tl_leds,
0 W3 `8 I: q5 ~& r .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
2 |$ ^6 n* E3 j7 }$ Z+ x2 J$ g};
# |" d# O& W- h2 z
0 r4 M( @1 ~! ?6 lstatic void led_dev_release(struct device *dev)+ s+ g2 M5 X& z( c$ D$ l4 q
{% V4 B6 ]. Z) w
};
8 s$ w* u+ v# X) X! I
' X! \% |0 R6 ]! `2 |3 Tstatic struct platform_device da850_evm_tl_leds_device = {
" S7 O6 X4 i; f& } .name = "leds-gpio",. J) s: k, i% x3 ?* w- M' o4 c
.id = 1,6 ~+ A8 [3 p7 S( e. R
.dev = {( E+ m' O* W% b0 B* a
.platform_data = &da850_evm_tl_leds_pdata,
9 u% {& B3 {+ B& v9 ? .release = led_dev_release,
4 F! \" J2 W+ E8 D$ y }
# m1 a: R& R+ i: i};7 }* U$ ?% j- v" C& C. _+ v
* c+ \, T* d% I" ]4 C# O
static int __init led_platform_init(void)
* x3 e* w# T4 k/ d$ H9 O{
1 {7 D0 h- n6 N int ret;; c) x% [8 B; i+ Z5 P
#if 0
& {. y8 ~: \- C/ f+ P/ f0 M4 b4 b8 \8 z ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
6 Z) p. ^+ x+ O% h2 X, @ if (ret)& O0 O8 h5 C: @: R( k `2 ^+ v
pr_warning("da850_evm_tl_leds_init : User LED mux failed :") g: }, Q6 W8 x( A; y! C
"%d\n", ret); x+ R) s* |/ I, M+ S8 n* q
#endif
- O+ x; G! [- g0 S/ `: N8 C; b ret = platform_device_register(&da850_evm_tl_leds_device);
. i; ]. Q# z1 F0 w! E if (ret)
% K& W5 A; L5 B. f/ M1 ? pr_warning("Could not register som GPIO expander LEDS");
- U, z. z8 i1 e* M else
2 |, h& m. B& i# W8 g printk(KERN_INFO "LED register sucessful!\n");; i/ r: O5 N! b! r t* D5 |4 L0 \5 X
+ M4 ?- e. ^) z* N6 U return ret;
; u; X, A1 m( c C, T}
/ E' p" N% q5 r" j8 I$ V$ E2 t v5 y( h
static void __exit led_platform_exit(void)
' h+ U, W. w7 F{
, p8 U0 \ B5 i9 W7 g platform_device_unregister(&da850_evm_tl_leds_device);" K( h! I' L, H) }3 U! o% M; R' `
! W- E) i% h) h1 S* K printk(KERN_INFO "LED unregister!\n");- m. Z" J7 ~. _; `& f' C
}- M. T' m+ J9 K7 i1 L" P, _
h3 ~! o+ a" {module_init(led_platform_init);) \9 Z7 \6 B/ _# s) d; Y% `! [9 m( v
module_exit(led_platform_exit);
/ }) L3 m/ w+ z7 o; X6 k/ k X0 h3 @3 |2 k7 ^. q; k& u+ m+ j
MODULE_DESCRIPTION("Led platform driver");. w! V+ e9 \; j2 `% T
MODULE_AUTHOR("Tronlong");
D! B* G6 N5 O) `6 B, TMODULE_LICENSE("GPL");( M) c3 `$ s/ \
# D/ b( @+ Y1 S+ g |
|