|
|
求大神给下面的程序做注解,请稍详细些,谢谢。( J- y% k1 j. G" c
#include <linux/init.h>
2 L. c" o2 L: B1 C#include <linux/module.h>
$ A m1 M' N. ^3 U7 e, k#include <linux/kernel.h>' x" @2 s) C3 v I# p( _
#include <linux/types.h>
& L% A+ s8 M- g7 ~0 U#include <linux/gpio.h>9 E, o8 d$ k% j1 f, R. G
#include <linux/leds.h>1 l& e4 X) |0 p2 e; r& T: E
#include <linux/platform_device.h>; b% L, [# m; o9 W) X7 c' U6 C
6 m3 W8 R# u" ^# m6 N9 r
#include <asm/mach-types.h>" g8 G, H3 C8 s& n: ?7 {; e
#include <asm/mach/arch.h>
4 L. d l1 { A, q% f' s#include <mach/da8xx.h>. g6 |6 q% d: T3 b/ z; K5 @
#include <mach/mux.h>
2 F8 L1 q+ f; r% L3 d5 Q3 z) f+ Z* M* v! U) j% B- L- T8 [
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)1 U, F( Z( r8 i1 o. x* a8 k+ c% x! X
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)6 O6 U" b( C' u. ?' E
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); P! H, H( i; g# l. W0 e, S( E( a
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
9 v$ o0 d- o$ {" `+ D; [, H( ]8 |6 ]/ p% L( h1 j
/* assign the tl som board LED-GPIOs*/
' c i$ M& {( w: P& J$ q* tstatic const short da850_evm_tl_user_led_pins[] = {
+ z- U4 m# E3 n /* These pins are definition at <mach/mux.h> file */
0 h- w- D9 [: s4 e DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 ~ Y$ ?- z* i+ h
-1
; a# l3 ]) p2 s$ n9 n0 Z};' _& ^5 O$ X9 {
. d# M$ \7 c& Q0 tstatic struct gpio_led da850_evm_tl_leds[] = {
" {6 p3 E' G( f1 M {
' N& _! E+ C" C .active_low = 0,) W1 o" X( N/ ~, F( ~7 h
.gpio = DA850_USER_LED0,9 I( x* |2 u- P3 T2 j
.name = "user_led0",# U1 c. K# L! N4 i9 v7 T* `
.default_trigger = "default-on",
/ C$ V& M0 D! [& R% B" j }," p2 ?3 o. A8 [2 |
{( ]- k! p9 \' H; F
.active_low = 0,
! K* f# @ j: Y .gpio = DA850_USER_LED1,9 Z9 f) `" Q+ J3 o& C
.name = "user_led1",
1 V6 i+ i) M6 r" L) M7 x/ U .default_trigger = "default-on",
8 I9 p+ o6 `+ _. d4 Y },, E2 n. ?4 j" j5 b* e6 ~1 x& d
{
) V2 |2 w, X5 y! V k j3 x .active_low = 0,2 v0 H5 b# D/ k, k
.gpio = DA850_USER_LED2,4 L: f4 r' F4 [6 S' p) C
.name = "user_led2",) O' U- F3 W: I9 V U3 t
.default_trigger = "default-on",
" q; }2 o# A/ n },
E0 \( J: t9 K8 r' \) H2 i {$ E4 A7 f9 w) p: f# R8 m
.active_low = 0,, R/ }( Z5 t7 ]" c' }
.gpio = DA850_USER_LED3,
' b" }: O) P5 R .name = "user_led3",
- ]7 G: d; | }/ I1 |) a, G .default_trigger = "default-on",
1 S3 V& E* a) O/ y% X },
. A$ r1 v' M( c/ _: p7 g; k& @}; S1 t8 |2 `/ ~, R2 S
3 S0 S, ]0 h. `1 S* {, Ostatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 j: E+ g4 b2 A' n3 ? .leds = da850_evm_tl_leds,
% a/ t$ q# ~! b .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
# y& B4 C. J p( f8 _) ?. {};
& ^; ~( r5 Y$ Z- c: D& O( w( u$ I) J6 C4 B' Q* m
static void led_dev_release(struct device *dev); g3 R+ j ?% \2 ~
{
4 e( R5 u' }5 O, U% A3 H/ ?};1 C2 e; X$ h( h
5 l3 C! K1 n! o9 \static struct platform_device da850_evm_tl_leds_device = {
. n4 D/ f3 P; N# B7 T8 p- B .name = "leds-gpio",
2 s8 M" r r: y3 f* h .id = 1,
+ J! P1 r1 T! s: R, M .dev = {! b: V( m& s6 L4 d% k; }
.platform_data = &da850_evm_tl_leds_pdata,1 i' i% t) W Q; U
.release = led_dev_release,2 V U3 U& P3 U5 s
} m t2 H j# z1 Y+ c1 C
};( R% g4 C! \% A/ }7 [; Y
; w8 U! G G# q0 s9 t+ g3 t1 Q6 Q1 P# ]
static int __init led_platform_init(void)
: ^. B: M% f& N, u B5 W Z{
+ C; F" N* J( ]) _- \ int ret;) ^: _& |, H+ U9 ~& n3 @" W- H2 ~8 B8 T( |
#if 0
1 `6 ^ r3 t$ Y0 K! c5 B- x ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 ^: g4 b" f% w. Q2 o' R if (ret)
+ G4 i/ [; \- h& u3 Z pr_warning("da850_evm_tl_leds_init : User LED mux failed :". s/ p6 f% t, o
"%d\n", ret);/ J( L2 g# ]) f. y' F3 S
#endif7 i$ P, f: B7 A; S
ret = platform_device_register(&da850_evm_tl_leds_device);
5 t% k) N0 Y4 Z" [6 e$ U; t/ e if (ret)4 s1 Z7 i6 m2 [
pr_warning("Could not register som GPIO expander LEDS");
6 O$ r0 ?( b: o" l' T5 w else
9 Y- O4 ^) |0 N printk(KERN_INFO "LED register sucessful!\n");
- D7 S; X8 {8 `
% q9 H, W) g0 i! p& H return ret;
6 K4 j4 b: c$ `6 _% H9 e: f! M}
3 _- R |0 U' f; {: i/ Y2 G' u# G
static void __exit led_platform_exit(void)
9 I2 t& }3 b. E: M2 H2 {2 h{! z: Z( I; Q A
platform_device_unregister(&da850_evm_tl_leds_device);
4 g' l; @4 l" n) `4 X& h/ g8 Q; j/ S
8 [. ^( c% v' b" R/ N printk(KERN_INFO "LED unregister!\n");. ?8 Z. I9 d" h# n. [
}
' b1 Q* g$ t) V# [: i" _
( U2 ~' J. g$ k# i6 d( n+ \) Zmodule_init(led_platform_init);. z) V6 r5 l+ V3 t- g2 i
module_exit(led_platform_exit);* i* s9 i: u! C& k$ q2 e2 U, E
1 n, g1 a7 R5 R/ a9 o) ^MODULE_DESCRIPTION("Led platform driver");
8 M5 L& N2 k# kMODULE_AUTHOR("Tronlong");4 c' E6 P& `$ a) ], h$ }4 H
MODULE_LICENSE("GPL");( [( |# _5 \0 z. G/ G" u' G
. V- c7 Y( w6 ~ L: W I# D/ l |
|