|
|
求大神给下面的程序做注解,请稍详细些,谢谢。# a7 w3 h7 K& H; E
#include <linux/init.h>
1 y7 H: H0 w2 Q3 X* M1 j#include <linux/module.h>& E) E# h$ r- M" i. Y
#include <linux/kernel.h>
5 J! y& I) b6 F% b+ Z% |2 S: G#include <linux/types.h>
4 B4 u4 ^# B' g/ T9 P+ I#include <linux/gpio.h>
( E" n8 Q6 U" \, W; R) _#include <linux/leds.h>1 i! U* H/ o, u m/ T( h
#include <linux/platform_device.h>4 S% a2 t# M0 h, K$ _, H! c
! A% @, ~7 d# y; r#include <asm/mach-types.h>
. X$ Z, Z, k5 N V: `! z! z& b#include <asm/mach/arch.h>
9 g5 r8 v& R1 y! O2 r8 g#include <mach/da8xx.h>0 D; M) ], g$ P' Y
#include <mach/mux.h>$ Z0 [- B2 I9 W- C: [1 T, w4 [ g
2 w E K4 J- g! {9 i/ }) d
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
3 T- `2 f: |8 V S/ z0 N# O( v#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)" \2 v5 u" Y9 E2 E) k& _
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 t$ w+ n; t& H5 u5 u#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( ` ^, }/ [$ d m
% L. V6 l) B6 Q+ L7 W# P/* assign the tl som board LED-GPIOs*/
4 h- V" ~6 G( I3 @$ V" J8 Y8 Bstatic const short da850_evm_tl_user_led_pins[] = {0 ^# j/ u* V: L/ t6 Q7 R/ [0 C
/* These pins are definition at <mach/mux.h> file */8 ~4 z' U' F1 u7 J* S$ O( F
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,% i0 p, D7 b( ]; S# i8 C- P& Z- |
-1
! o; a0 Q, ]( o};/ U2 i+ Y# N5 Z, Z
1 L- ~1 M# l2 n4 Astatic struct gpio_led da850_evm_tl_leds[] = {4 f* M+ ~$ j7 D& A0 b3 Y
{6 |8 s& {; w! _1 Z3 B3 a% b- Z$ e- h
.active_low = 0,+ p% I) G5 o6 V @
.gpio = DA850_USER_LED0,
- O" M; p6 {8 M: C% T .name = "user_led0",
% _9 `3 i# o9 B, f# M .default_trigger = "default-on",2 u: \. B. ^4 z5 g1 v
},
5 k7 G: _! p5 s9 H& d7 g' J X |; S {
- ^2 K$ b" i' n; M .active_low = 0,
& S3 C& _. l( v1 U .gpio = DA850_USER_LED1,
0 j$ Y8 B/ n2 s+ ^1 J# J .name = "user_led1",
& G! G: X# U4 Y .default_trigger = "default-on",
j' Z3 Q8 k, n4 P3 `/ x },% i+ V' A4 ?4 }& |4 [
{
, {1 E" a! z$ v& U* _6 o/ j) i8 L4 Y( @ .active_low = 0,2 B* d7 d( _( ~+ z) R0 N% y3 i
.gpio = DA850_USER_LED2,
' H4 ?: T4 j( |( H8 c2 o& u .name = "user_led2",0 H0 q8 U1 _! h6 B, k0 y* p% E
.default_trigger = "default-on",' O8 A1 a1 p4 R) q) d* q
},% w- a& V$ V) f" Y+ a- r
{
: T7 Y/ u9 T% o z .active_low = 0,5 f u; n3 l/ d0 y+ t
.gpio = DA850_USER_LED3,2 s7 S9 v9 h* a- b: D/ V! s3 w
.name = "user_led3"," I% H/ [/ r7 G) A% g
.default_trigger = "default-on",
, d& V- C2 r) U4 Y },
0 T% x+ d( A3 y2 V};) m: i2 d6 j, Y! w0 l; y8 b4 W
( z5 |; K7 I# F& K4 J$ I, x
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {" H0 j- P( s9 Y8 {& ^( M' Z0 l
.leds = da850_evm_tl_leds,
F4 R( C; }" b7 t: d' N .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
9 q2 j. |+ g& M6 }* C};
( V: P# C1 ?% W, n- A* p" E q6 x0 K" T7 g
static void led_dev_release(struct device *dev)
/ {# @& T- H9 ] X+ _{
, h! f; |' `+ D1 |};0 ^! V0 P. l9 r$ ?
$ d* d9 X, E8 O6 q! H; ~
static struct platform_device da850_evm_tl_leds_device = {
+ \( \7 I! \4 I* Z$ m7 o .name = "leds-gpio",0 H* K7 Z) V3 s9 q- w5 Y! o/ P
.id = 1,
% e3 A% D4 u; v( O- D .dev = { D2 D3 g7 a% [, U) I8 G6 y
.platform_data = &da850_evm_tl_leds_pdata,$ r4 ]* p* E- T" a' A
.release = led_dev_release,
/ Z- A! Y2 J& i. h& h }* j/ h, n# [0 J. k3 m& G6 ]
};5 \( D7 w/ I$ s p* Q
. j& H( c* Q9 R+ e" I1 Nstatic int __init led_platform_init(void)
# x, |6 K; i8 d$ Y b% f{( c9 l* @* G5 B. y: [
int ret;
2 d" B1 t$ X: t* j0 g! Y) `#if 01 T3 Q! x) H# _. {3 f9 h/ j( Q
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);3 b0 v! N2 V7 j. m+ ^- `% I
if (ret)
# h1 U4 l: L" N; g pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
3 b3 x+ M0 i1 w, m8 W5 \! Z0 d "%d\n", ret);
1 O4 d, f; ?- i. w! u+ o) ^#endif4 S2 _" l- I0 F: y3 r( N% L
ret = platform_device_register(&da850_evm_tl_leds_device);0 l5 m" O' I. _! R
if (ret)
7 {/ a0 |6 o, f- f pr_warning("Could not register som GPIO expander LEDS");
# p; {7 E2 ~+ |( ]! \ else
9 F7 A: t0 l3 g3 _ printk(KERN_INFO "LED register sucessful!\n");& T' j; M& B; e- ?9 k0 v
- ~; R3 X5 \ ~9 z return ret;/ u( k4 Y4 I$ M1 M( g8 \3 Y
}
" L% p) L+ u: `% _6 ]% ~4 I/ h, r: I9 p
static void __exit led_platform_exit(void)! t4 w& a2 R5 r7 j6 o. v( T0 \5 i
{1 r0 Q: R% \! D2 N0 T
platform_device_unregister(&da850_evm_tl_leds_device);
( u \/ b" d0 m2 h' s1 ?' N8 I; k: |5 o! ?0 ^6 z
printk(KERN_INFO "LED unregister!\n");
& B9 T. B$ D6 q8 [2 T8 J}+ j7 \3 m4 [$ J
; _( x; z; H+ n. U! Y
module_init(led_platform_init);) W4 X/ [+ a! e. v; T& P
module_exit(led_platform_exit);
/ G8 J7 l3 I7 ?8 w" l9 `1 j& s" U: t9 t8 C- V5 a0 t
MODULE_DESCRIPTION("Led platform driver");# p/ L% ? L5 x% ^! N* o3 a9 K
MODULE_AUTHOR("Tronlong");4 t4 H; k# `$ t% a! N
MODULE_LICENSE("GPL");
) J% X8 A# G) `& b% ~
' Y( b5 G, Z6 \( `2 k |
|