|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
! A* ]/ J+ q" [6 U1 T7 e& ? n s. z#include <linux/init.h>
4 k, P, w" D w' s; V g. f8 _3 C#include <linux/module.h>
* |2 O& }2 t1 G3 [ e#include <linux/kernel.h>
) I; [2 @5 l' o% \6 b) q#include <linux/types.h>
$ y' E. f" j1 p: P- C#include <linux/gpio.h>
8 J L3 L1 C4 H( z; b/ r4 u#include <linux/leds.h>
) C8 P. Y4 B* N3 w7 @#include <linux/platform_device.h>7 D0 j& c) u' S
N; K3 q9 Q% Q6 r: m
#include <asm/mach-types.h>
# u" M- G6 a$ X) B! E3 e$ P3 i#include <asm/mach/arch.h>
& m2 K( K s T" Q#include <mach/da8xx.h>
T' ^6 S4 s" u; T6 m' q#include <mach/mux.h>
# g& ?# G( V) R" m% m+ @: r7 ]% D& l. `2 _
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
- j% N7 A% W' Q7 `#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)/ ?% @$ e! i8 e+ p' K
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)' {8 `9 g, t" A8 N: P# t; y
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; g+ |3 S9 P/ I4 P i5 L1 Z" y- |9 |2 x4 p1 L0 v
/* assign the tl som board LED-GPIOs*/
$ _0 W# Z2 \* I }$ k( {6 Istatic const short da850_evm_tl_user_led_pins[] = {5 s! \0 X8 |# S) z/ ^! g) J
/* These pins are definition at <mach/mux.h> file */# H8 t& L/ x p/ Y
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5," p/ c' c' q1 ] B
-1
! w5 m/ o* t6 ~3 s% D- C( B};
, J3 H7 g: L8 z- k8 M, J& B
, L& f4 Z9 j6 Q+ M" ustatic struct gpio_led da850_evm_tl_leds[] = {
- B! d2 v$ U* `& P2 k( P: U3 F {- Y$ u$ a/ u# a. o
.active_low = 0,
* @9 {3 {) z. d" W$ Y .gpio = DA850_USER_LED0,# m& ?. E+ P) [9 [8 _
.name = "user_led0",
# B4 U" m j+ g. R# D% A .default_trigger = "default-on",/ M0 W; O! o, x' H' H) `$ N# q
},( S, i/ Y- A5 Q; O1 ~
{- u5 T9 p" R6 f- t2 g/ d
.active_low = 0,
7 a0 K |' x1 A .gpio = DA850_USER_LED1,
+ @: ^" {. W5 _/ f" L; n. W9 U .name = "user_led1",
5 }( E7 P# Z4 k& _; D .default_trigger = "default-on",, q/ J9 \3 d% B; B* @6 ^! f
},+ ~4 f7 y' g8 x9 \9 ]3 L7 m& M
{
9 i' @; a: M' e! I# L& B0 C .active_low = 0,
9 ~4 N, {) h% I. L! V8 F$ O+ X .gpio = DA850_USER_LED2,- \. r3 x- \' y
.name = "user_led2",# J' L3 q) z4 r( |6 A9 D5 R3 K
.default_trigger = "default-on",
! o: |$ r, |. h( Q8 g },. s, E w, p! f/ E @$ L! U
{5 x# d' x# ^4 ?
.active_low = 0,$ a) p; j. C1 q7 y; e9 [
.gpio = DA850_USER_LED3,/ g$ X8 n% X2 S. ~ T* l1 O, V
.name = "user_led3",
* O G, ]- H) H. S* Q& ]: [ .default_trigger = "default-on"," N$ k1 m/ z. o3 G) x l0 h7 A
},
* S/ s! }" G% z};
" j7 L4 A- l3 L- b5 w; D5 u4 r
6 i/ s5 C2 n( i! P% Zstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {* E6 e5 s! T# Y0 ^7 ^7 Y6 C& Y
.leds = da850_evm_tl_leds,5 |/ q; d) c7 f+ \$ P9 i
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
7 [. k( `* O4 J/ |& l/ \' l; B$ c};9 g! D+ _1 ?% u. ?0 }8 g
4 w6 Z7 `$ g+ Bstatic void led_dev_release(struct device *dev)% v- ]$ B$ o9 |/ c9 y* L( x# |
{
- W+ a" u4 U T4 M};
1 F H6 M7 S( k! e) l! m- K; D, ?% \/ A( h5 ]( C
static struct platform_device da850_evm_tl_leds_device = {
7 n; m# g8 M( \8 `% \. Y; U& h .name = "leds-gpio"," y1 J- a; H( V: E6 r1 {
.id = 1,
% n1 V* \; {$ d6 O8 }9 W .dev = {, j8 \# {& | ^0 l3 O7 k+ L6 P
.platform_data = &da850_evm_tl_leds_pdata,7 O# I3 I9 i& l3 r5 M6 I9 \
.release = led_dev_release,2 d& D6 |4 s- D; F3 S
}
1 y6 I7 U" T3 b* Y};
0 o/ @; B0 L' G6 X2 Y$ e h, L+ }& S* N. ^; x
static int __init led_platform_init(void)- ~) M: ~! x7 Z" N: H# {- A1 W
{
0 D+ E" B; y [$ F# E5 s+ k int ret;
6 V! L! ~" H0 i#if 08 U6 r0 q# L4 N( {
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
+ |( W8 Z0 S3 y7 ` if (ret). L3 f, W8 }1 ~; T% m: T( G* ?
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"- P. J. g6 ]8 g# E
"%d\n", ret);5 n! L' c g& Q' ^0 ^
#endif( {% d6 B# o- M3 P5 ^3 u
ret = platform_device_register(&da850_evm_tl_leds_device);
5 C7 b6 u+ U+ f1 \# n7 B if (ret)( O$ ?, N2 g( w9 t
pr_warning("Could not register som GPIO expander LEDS");
. D' R3 X5 M( O8 d% g, h* R) z else
9 k1 c% _8 C8 C+ ~( E: u& c printk(KERN_INFO "LED register sucessful!\n");
" z& u. E" y% t
; ^( ^' X9 F. n6 K return ret;
" d3 T1 k) y+ j}
7 K1 N2 }7 p. }0 F: e9 w* q9 j7 u! ~; F
static void __exit led_platform_exit(void)
) Q/ y$ y/ w8 C) d2 i( t9 n{
$ u$ w' x% h' b. u5 q7 _ platform_device_unregister(&da850_evm_tl_leds_device);
! K" l& k G2 {1 d2 y' x5 S$ k# G; z/ R) D5 J8 p/ S
printk(KERN_INFO "LED unregister!\n");3 `" i8 m+ N; Z% {: ^
}
( T. s/ E$ g8 H7 [+ U) q# ?8 `& w: v. x2 f l
module_init(led_platform_init);2 v% M, ^. Y Q. R5 J: t
module_exit(led_platform_exit);: x' M* b$ f, n$ G+ G7 @- i8 l
( ? @- W( Z4 ~0 O+ B
MODULE_DESCRIPTION("Led platform driver");
7 H+ E! Z- s; I$ F7 H* p- V. AMODULE_AUTHOR("Tronlong");# l$ N- `9 \) G. q: p: f
MODULE_LICENSE("GPL");" J, o9 v. |( b" t8 n! U
0 X H+ {& K& T1 M6 F" l5 i9 x
|
|