|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
' l% U4 A- V% W- T9 O6 Z5 y#include <linux/init.h>
* ?) T$ R9 _9 ~#include <linux/module.h>- D( c: A4 v! z( N- k( A
#include <linux/kernel.h> ?( B( O# H- o+ M. [
#include <linux/types.h>2 j2 a1 b1 `8 n. _) l% A
#include <linux/gpio.h>1 B# s2 N4 j6 J* z9 `4 M( d
#include <linux/leds.h>9 @7 l/ H, m8 f$ }
#include <linux/platform_device.h>. x1 M6 p: r! w' f
) n( X. d/ |, q% r1 G#include <asm/mach-types.h>% n* \0 ~9 ]# l& L. u
#include <asm/mach/arch.h>
6 q; D' I9 Y- r* O, [' l" |#include <mach/da8xx.h>
1 n% S* f* V; r; ]#include <mach/mux.h>
7 B3 x* Q2 ?' ~3 q$ y, v. e; o
" D/ |4 b6 W8 e7 n4 r* W0 m% y#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 j" G1 `( _) F; E
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
w) L$ E4 g" Y2 z& C#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
. ^" j) _# R1 Y/ u& p#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
- C% }6 i/ j4 X# H! E5 Z
* ]0 F% f( U% H( J+ S/* assign the tl som board LED-GPIOs*/) p2 w4 y7 a+ I: g* u7 ?* }2 u5 @
static const short da850_evm_tl_user_led_pins[] = {$ @5 O x; Z" X7 }& L
/* These pins are definition at <mach/mux.h> file */
4 u& ^% n9 t/ I0 v8 }& F DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,, o8 q7 r8 l" X
-10 d" f6 B$ H' i& d& R+ O6 t
};( m8 x" e$ d/ v
% O) e6 ^0 C7 ~) f( v
static struct gpio_led da850_evm_tl_leds[] = {
/ a" A3 I1 t3 N3 x J. U {1 g! k" x1 e5 _
.active_low = 0,
8 `. H- E6 i) C3 b% s% a% W .gpio = DA850_USER_LED0,
' `: {" Y4 v* a/ @0 R/ h .name = "user_led0",
6 [7 w1 R! Z& a# @+ ~ .default_trigger = "default-on",
. D3 r- q! R* c3 ?+ O },0 s0 P( M& ]5 d: ]; o* X# [7 f* b
{
! e& t, X' R& b% d+ u .active_low = 0," v, \& i" r$ F6 `7 e
.gpio = DA850_USER_LED1,1 g! l3 y8 n( ?4 o+ Q# d
.name = "user_led1",5 `$ }: J; F5 u5 |1 z
.default_trigger = "default-on",; j$ n! A. R6 I L8 |9 X" ^1 Z
},
1 b. [( n5 p( ^4 M$ w F {$ Y q9 Y) S1 Y( }9 K: M
.active_low = 0,
* u! a% W, g- Y .gpio = DA850_USER_LED2," Y' t7 | B+ P
.name = "user_led2",% U2 [# A7 i4 j. ?. L7 f8 B1 Q
.default_trigger = "default-on",
. Z3 p' x$ j2 P8 w- u/ C5 }8 s& ^ },
) t7 @1 X/ `1 \8 |$ e& I6 O {/ _" S7 n9 \: n* c
.active_low = 0,
/ h0 _7 Z: j' _0 r .gpio = DA850_USER_LED3,2 z* H2 u6 B+ W
.name = "user_led3",
$ u, ?( P S" c .default_trigger = "default-on",
$ U0 Y0 J X# }7 i },8 n3 s1 r+ E# G" @3 z) R- {0 ]* R
};: B8 r8 K6 }, z# s
: @" N8 [9 L& P7 |- A
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
/ B, ?' q+ q2 I- ]0 V0 w/ w .leds = da850_evm_tl_leds,1 m5 [0 {# a( w' N# ?! a6 U) }$ Q
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),' m' B- x: o3 E" u+ ? Z2 ]
};8 s( w4 S9 r8 t" X6 F4 K9 }
0 f5 s5 E; b: g3 Z" R- s# \$ r8 |static void led_dev_release(struct device *dev)$ a0 `* [# Z( }' ?
{
& @8 s% v: V9 t" r- g};& E3 _1 ?# H+ U) Y% k+ a
$ Y4 C1 c" q, k* R5 O# ?5 C2 E/ h7 {' R" m
static struct platform_device da850_evm_tl_leds_device = {
7 G1 O5 B4 a+ {4 P$ P) ^ .name = "leds-gpio",- Y7 v1 G) X" A9 C; R2 O
.id = 1,
8 R: T5 B3 K( `" @# d. a .dev = {
1 h0 ?$ s F0 ?# O! {- c .platform_data = &da850_evm_tl_leds_pdata,1 U- c& i6 j! x: q/ x& n/ H5 i& ~, ?: v: X
.release = led_dev_release,1 Y- I p5 U/ j) L1 a
}
% T5 q$ t) \; ]2 }};
9 l& L4 h9 k3 [( n
; j$ b# o _5 v8 k" n9 \3 istatic int __init led_platform_init(void)9 N2 j/ }- W9 h
{, H" W( g. F% y
int ret;
) c( \" @- v0 l1 U, o6 R#if 0
. N% \+ ]+ a8 @ ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);$ a \ Q2 G: b% k# Q' s, z& E
if (ret)
- `8 N" E4 q- I. b" } pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
; U. l0 h! F/ k/ K/ H& z ? "%d\n", ret);$ |4 d' V) \5 @' l5 i/ n0 z6 Q4 i( H
#endif
# b0 E0 h$ t. f! P7 I ret = platform_device_register(&da850_evm_tl_leds_device);
2 x+ t: v( p' B4 l( u% U. _: T if (ret)
# {* M, ~, V# n) ` pr_warning("Could not register som GPIO expander LEDS");
. j! A B' U5 t1 V8 {9 m' d% `% i else
+ F8 Z) M B( d$ D printk(KERN_INFO "LED register sucessful!\n");
% s4 p3 Z7 I' H* s6 t# M/ B9 i# C* ~* E; H8 {
return ret;
, o: u# K8 g) q: h% c}9 ^8 m# l! [# s6 a" o; Y1 T% r* ^1 c, d
l$ F, Q6 M' }+ B+ s
static void __exit led_platform_exit(void)
1 H( M, r& \- U) A8 Q" s{ v0 } `/ `3 o3 D, x4 @: |, _
platform_device_unregister(&da850_evm_tl_leds_device);6 V: D+ G6 c( T+ g# |
5 B6 A: B6 o7 z" a: p% ? printk(KERN_INFO "LED unregister!\n");! B- S0 N; A7 F) x1 z, p. V
}7 Z3 X# @6 K- b1 w0 v
6 F6 ~2 M% P% Y' e; p/ Cmodule_init(led_platform_init);' T! ]- J( |* x; k, i3 j% z9 c
module_exit(led_platform_exit);
+ M! y& Z' r+ S) Q) A3 k6 w9 a, s7 R! R
MODULE_DESCRIPTION("Led platform driver"); k2 n' b& c) N! c$ r. g# y7 \
MODULE_AUTHOR("Tronlong");
/ E/ Y- h) C, t. Q2 kMODULE_LICENSE("GPL");
8 q* ? F2 ]- k1 B2 ~5 M/ f0 P/ [
|
|