|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
4 r- ?! m; _$ p, _#include <linux/init.h>
, P7 S# {( Z8 c- ~- m#include <linux/module.h>- d: }9 Z2 Y p% @, m& F+ B* t
#include <linux/kernel.h>( C( O7 K: d3 J- a- `& \
#include <linux/types.h>
7 a b; d8 G/ h; g#include <linux/gpio.h>3 S& K- C1 P" a5 U+ u' i2 W% ~
#include <linux/leds.h>
! B( T* z# N( g" l#include <linux/platform_device.h>
9 H: V# Y1 S5 B* e$ K/ ]+ k" J% W h! Y, Y7 r
#include <asm/mach-types.h>
) D2 \% c$ B9 K) O#include <asm/mach/arch.h>0 R' M0 g8 L# }
#include <mach/da8xx.h>
- @+ o/ E! K* Y9 B4 z( n; E#include <mach/mux.h>7 T. l# R$ J" U" }
0 u5 w0 V4 } C& S! u
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)- H2 }. T V! W9 \6 Z! x6 r
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# ^( Z& p5 e: s& V/ w" _" M a
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 q1 ~4 D/ o+ Z1 w7 |3 H7 T' R
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)4 r$ ?+ H7 r& G; d( z1 W) }
+ t0 q% {9 s7 g C& S' A/* assign the tl som board LED-GPIOs*/8 s+ G: ]6 @/ j8 N# W. w9 D
static const short da850_evm_tl_user_led_pins[] = {
8 @$ y( ^6 b4 S, L7 D& h+ [ /* These pins are definition at <mach/mux.h> file */! [3 b2 D$ P Z% R1 {3 y6 c2 h
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. n3 L8 I8 o5 S* D" ^9 u
-1
% }3 d! H5 Z: \2 h+ |};$ @9 F2 i. E y
& o/ L' _& L: |1 N! Bstatic struct gpio_led da850_evm_tl_leds[] = {: h/ e$ [" ?) ]
{. ?# S& D H& y
.active_low = 0,
9 F5 c" T) m3 k4 k! ?- ^. w .gpio = DA850_USER_LED0,% G5 E) @( B; A" R) b2 \
.name = "user_led0",
) s* P! {% T$ O5 t2 G .default_trigger = "default-on",
* p- |" n! R( f+ L/ h" T( m" g },+ V/ l4 X. H8 ]- V# }" z
{" O. i7 s1 ^: }7 r1 A- B; ^$ w: ?
.active_low = 0,' f' a) X8 _/ l) x
.gpio = DA850_USER_LED1,
0 b) z. u- [( R3 ^) Z' T .name = "user_led1",
( r" H% V' B, [8 V7 D .default_trigger = "default-on",& D) `! t5 @! z8 O( ?' \
},
+ w7 @- ]. U6 z) H, z {
( r J. n6 P0 D8 S1 w, W: e .active_low = 0,
4 I2 I. v3 @% N .gpio = DA850_USER_LED2,
8 f$ R3 b. p" H9 ] .name = "user_led2",$ [" d+ J# g X3 V$ e% K! o9 j% K( p
.default_trigger = "default-on",
, ?6 M* ^3 S5 J* H. n3 [% K },
( E5 h6 L3 g' R1 S% s/ q {* C# K7 K+ {5 y6 D+ S
.active_low = 0,! n, o2 ?1 X% W' Y; K1 p
.gpio = DA850_USER_LED3,
' S2 [" l+ Y3 G* f! z; W) T .name = "user_led3",
5 n9 F8 g( `& f4 q0 B .default_trigger = "default-on",
( g( o* Q6 a9 K& j- a8 A3 w2 E },/ h' ^) W& S8 j
};) D% ]3 i4 K6 Y! U% |
6 W- u1 d' k: u# C' n. B' v/ q7 k2 D
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
- f+ n0 B: p/ U/ K; ~. C$ R G3 S .leds = da850_evm_tl_leds,9 `. Z7 d! o, G$ u, I
.num_leds = ARRAY_SIZE(da850_evm_tl_leds)," P% Q1 ]/ O2 `3 @+ v
};
' p+ J0 l( U/ ~/ ~* p, ]1 L* I( C r
static void led_dev_release(struct device *dev); ^: `2 v$ U* s9 ^2 y3 m
{
+ u; @/ u+ T6 c/ n+ Y2 ^};8 \ P ?0 o; M7 @
2 L- I9 J1 Y/ G, ]) G$ J! y# W& Y, M9 ?static struct platform_device da850_evm_tl_leds_device = {
( U7 m) l# F% p .name = "leds-gpio",
$ P( G9 q2 o) @3 [1 _" \ g2 _ .id = 1,) X3 X9 I$ ^6 \
.dev = {
/ O' g/ W4 g2 `- i) I .platform_data = &da850_evm_tl_leds_pdata,
- c7 L; @' V/ Z( |" f7 t7 F! r .release = led_dev_release,2 w7 {2 `& O2 N' I$ B6 M0 y
}
, [) C3 i& _) k9 I! F) t# @};5 C, w! h5 N" R2 M
% ]. Q! ^1 Z3 ^7 Z d' b w
static int __init led_platform_init(void)/ k! f9 N M. b' ]
{+ G, D# \' }2 {9 M& E* x, q
int ret;' s X8 z( Q+ e0 M; h2 [
#if 0
; x- y3 x* T" l3 `1 s5 M6 F ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
0 c2 P, W- u5 s' v' t6 V1 B if (ret)
4 J! X4 v2 L7 C" W( F1 l9 E pr_warning("da850_evm_tl_leds_init : User LED mux failed :") X D' \- W8 z3 I4 O2 G% s
"%d\n", ret);
6 o! t0 S1 k Z; [2 s$ z#endif) [7 [; T8 ?0 W
ret = platform_device_register(&da850_evm_tl_leds_device);4 M. B0 T5 ?" p2 \6 a% `. H" k' p
if (ret)* ]. R! P7 K# x6 n* `
pr_warning("Could not register som GPIO expander LEDS");
. T4 Z+ C' ?7 |6 G3 [ else
8 c2 @- W7 {6 B3 ]( L% v printk(KERN_INFO "LED register sucessful!\n");9 ?5 B. o+ y# {# ^$ G9 a
5 X% W. z: d6 z6 D' q
return ret;$ ^' T6 \2 W, z
}
1 [# Y2 o/ f6 S W: T/ q7 b3 |) W8 U$ [
static void __exit led_platform_exit(void)
3 J( W0 y4 ?8 p. \0 Q ?' [ O T, _{' l/ p5 w) j9 p- J o
platform_device_unregister(&da850_evm_tl_leds_device);4 ~/ i# e9 i% G
/ X! h8 o7 A6 P2 l& ^, U printk(KERN_INFO "LED unregister!\n");5 |1 b, j6 p8 h8 F+ r- h# F g
}/ @ y5 D* N/ p4 z* j+ i3 }
: ]8 C7 r8 |& D5 P
module_init(led_platform_init);# ^" c3 M h- Q" w
module_exit(led_platform_exit);
1 Z: k3 a* s" V3 R
$ G5 d) M/ h$ `8 ?+ GMODULE_DESCRIPTION("Led platform driver");# N+ R$ k2 Z# }( q1 M( U
MODULE_AUTHOR("Tronlong");
! {0 f6 Y O, YMODULE_LICENSE("GPL");
6 L; u# `" G/ U l5 w; }) X
: u3 e# }( }3 p/ i2 h& G- E2 Z |
|