|
|
求大神给下面的程序做注解,请稍详细些,谢谢。 r) H3 ]8 B1 x2 D# a6 R
#include <linux/init.h>6 \2 n4 y8 \4 V" Q4 \
#include <linux/module.h>
; P+ ]$ O2 `; I+ ]3 n3 X/ D3 V#include <linux/kernel.h>% E0 g6 k1 y$ _
#include <linux/types.h>
+ A. r5 A& I' a6 B#include <linux/gpio.h>
* e y/ ^ ]$ [2 t( s2 p#include <linux/leds.h>1 o. X6 S x4 L, y# W7 K& N, ?
#include <linux/platform_device.h> e! p- o0 `& z7 z( x4 B+ [' K, u
. ^# R* t' r% a1 O
#include <asm/mach-types.h>0 A& {9 g: v9 s) f
#include <asm/mach/arch.h>8 A! t3 {9 v+ S" x$ |# [
#include <mach/da8xx.h>
2 ~) @3 _6 R* [0 @#include <mach/mux.h>! S; Q+ u0 i: s7 b; E6 S. M$ n4 h
$ h9 c3 L4 s' ~( u#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
7 F6 ^8 r# p6 f#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)# a& Y! u$ H5 p3 b8 y6 `# V
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)5 \2 W% m. R V+ ^' a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
# v6 H+ N; S( ^. ~7 b0 j- {. u& j9 B: n* J" ]
/* assign the tl som board LED-GPIOs*/' x; [( v2 V( j) c1 m+ m! T
static const short da850_evm_tl_user_led_pins[] = {& s% E- N3 B+ A1 d, W2 X1 ]6 @
/* These pins are definition at <mach/mux.h> file */
6 T. h3 {) \6 ^! e9 Y DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
! U: T) s5 B" J: X" S" Y -1
# H0 `* t6 L$ H- _};
0 Q( d# r: c# ?( U* A7 Q0 L! c2 ~( `9 i/ U( ?% s
static struct gpio_led da850_evm_tl_leds[] = {$ P8 A$ k2 f3 x4 P+ O; j
{6 z+ N: L3 g/ X7 u
.active_low = 0,
9 j) F: s- o. y; A' X .gpio = DA850_USER_LED0,
9 j( ]- u7 D: l7 ]8 K" n2 c' \3 |' m .name = "user_led0",
/ M. a/ y' { \! |6 }' a .default_trigger = "default-on",
; Y: x. v1 z( D/ y9 Q' m5 y; Q- p },
4 i# `- u0 p% n, h& W! k) n; Z {% Q9 K6 f$ E0 t2 H4 G0 E
.active_low = 0,
+ G) |$ ^0 O P1 o2 f .gpio = DA850_USER_LED1,) D9 w; I5 q! G$ Z# V+ y
.name = "user_led1",
$ f3 W- m6 N* L9 }. E/ X6 B .default_trigger = "default-on",
% i, X6 Z+ \% ~* I },' c1 v. l- e+ R s& V: Q# c
{ P) k% g1 L& f( V6 |
.active_low = 0,7 C3 @7 h: @9 q* j. E) A
.gpio = DA850_USER_LED2,+ P. n1 {/ J9 i- W( R+ w! \
.name = "user_led2",# Q8 ^2 q+ }6 V1 ] c- ?" O
.default_trigger = "default-on",
! w' ~2 _5 N/ C2 ?3 h },
! u6 X0 L7 K+ t2 T ? {
2 D$ S" ]" w9 @9 {# p .active_low = 0,% X _4 f/ F: D* C! {
.gpio = DA850_USER_LED3,% E( R. f2 O; r" R
.name = "user_led3",
2 d @( W5 J6 @" g* @ .default_trigger = "default-on",
; |1 B2 P/ L( f0 `' E& q L },
' |0 t2 y3 \0 ^9 J, @* Y6 F2 ]};* ]) s$ f3 j, C$ n
2 l! `2 D4 g: J0 |2 G$ A. _static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
( s7 B; q! b3 p% H .leds = da850_evm_tl_leds,4 V) m( U; G& X+ ?2 O
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),2 x9 b( R$ T5 p6 ^& X! Z8 C
};
+ L9 Y9 v- {/ d. b8 P% d1 e* ^& c+ A% Z7 \" S Y
static void led_dev_release(struct device *dev)
) S5 }: k6 k$ A( R8 G{
% S! P2 {- I" P};5 n% c5 H5 N9 s' A' B [
g, G2 @/ P, y7 G
static struct platform_device da850_evm_tl_leds_device = {8 k" P6 L) ?& r. A# o
.name = "leds-gpio",1 c; p: ^+ s- U9 K
.id = 1,- K: P; a4 [1 m! q" U7 `/ M
.dev = {2 Q5 U( }0 k" E b4 W5 V
.platform_data = &da850_evm_tl_leds_pdata,
8 E" s0 v0 t0 F w- p .release = led_dev_release,* C' D, F6 f9 {/ s* S! n
}- L7 a( t0 |; R* O. C6 Z m0 f
};
5 ~9 B' u% X: P% g! J, v4 o3 _7 ]* Y: w ]! }: [
static int __init led_platform_init(void)
! \6 ~) L5 r( g$ a* K# [: V{
- V; L9 {+ v" B* k: }! G int ret;
6 Z" u# `: _, I" m: |: a#if 0) o& \- h/ G$ B3 ^ y8 L& h) Y
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ K+ e4 } J% N5 [- I* F if (ret)% r, ~) R8 ]5 m% h5 P& ]& N F
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 t8 ]1 p, y2 V( T "%d\n", ret);* m$ h1 ?2 k# V% r0 a* ^( H. ?, c i
#endif2 z' d1 l; D6 M5 ?5 I
ret = platform_device_register(&da850_evm_tl_leds_device);* S, A+ i( s* B5 F0 s
if (ret)7 U9 `4 `+ c% T8 Q* c/ n
pr_warning("Could not register som GPIO expander LEDS");- ?2 h/ ]0 L1 k4 f" P* e/ P5 j4 V
else
# A+ b: ?- F5 M5 S printk(KERN_INFO "LED register sucessful!\n");& t0 r! s+ V4 N# {: u
7 v! e! ~# C9 J3 J F! g return ret;3 z# B) Z5 o5 n6 X3 b# ]# Y
}
& t# Q! Y* I9 o1 K$ c" d$ \5 I4 D$ @0 Y
static void __exit led_platform_exit(void)
6 N: x+ v$ ?" H6 j3 y; y3 D{
' K% g1 C2 B! W: E platform_device_unregister(&da850_evm_tl_leds_device);
2 F1 }& U- Q& U% _4 N. ~
7 M: J' K1 y e7 [ printk(KERN_INFO "LED unregister!\n");! Q2 n& L- i7 Y
}
; g. J! H7 m, J# v" f8 q/ D' v; R9 `7 G+ R" Y4 n3 A* T; T( a$ y. b
module_init(led_platform_init);
7 O, I( W1 _- O. w, }module_exit(led_platform_exit);, [- e3 O0 }: B2 B% }! x$ ^
/ Q. J1 Y" H7 qMODULE_DESCRIPTION("Led platform driver");
, g( n7 |% B! i6 wMODULE_AUTHOR("Tronlong");
8 |& o+ I( X: X+ TMODULE_LICENSE("GPL");0 |2 o& F6 E `
Q. m- V( x3 y- k2 B: y" A
|
|