|
|
求大神给下面的程序做注解,请稍详细些,谢谢。/ n V' {( d( d( A* D( k
#include <linux/init.h>
6 _) Q4 L* S/ F! O' _( X9 u#include <linux/module.h>9 V8 Z; \+ u: T# b- t& U
#include <linux/kernel.h>
$ l" Z) J1 w7 q#include <linux/types.h>! u6 w3 q2 ~# T# A
#include <linux/gpio.h>2 I! N4 z- r9 {* w
#include <linux/leds.h>
0 P; s- U9 B- \/ _* O. A; M#include <linux/platform_device.h>0 e! A* z4 p) v; L
! V9 j+ S5 t |; ^* K: o% u
#include <asm/mach-types.h>
0 C' } V* ]& K! Q#include <asm/mach/arch.h>5 L3 p* o9 h* L% r* k" t0 T) W
#include <mach/da8xx.h>
2 |% Q' ^1 A/ u3 B# R: O#include <mach/mux.h>) Y$ D/ _, g* a+ `0 o: U3 {4 c
6 Y! b8 V2 r% _/ S
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
2 w1 G$ a% N( A9 G% p#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
- z) K% N* a# P* s#define DA850_USER_LED2 GPIO_TO_PIN(0, 1) t9 B. L* J9 B$ a( B! {$ j7 b2 X
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)( t# Z, }# n. C& L
7 O6 }5 Z: U# b: {/* assign the tl som board LED-GPIOs*/0 S9 ]2 J4 S3 S: x* ]. L
static const short da850_evm_tl_user_led_pins[] = {
9 F! ~0 y8 P3 _$ N9 y /* These pins are definition at <mach/mux.h> file */( D9 Z1 V! D9 @" X: x
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,$ w$ z5 M! D6 o! m* v2 T
-1
3 Q4 E* @ A4 F};
: M' x1 |) A$ q9 Z0 t4 p; w" j, V
static struct gpio_led da850_evm_tl_leds[] = {
- Y6 m4 [; l# R/ c8 E9 F0 J {
0 N; C: ?: s0 B .active_low = 0,
0 t# ^5 f; K1 F' X- P: s .gpio = DA850_USER_LED0,
1 n$ X! M; N: T# A) H6 m .name = "user_led0",
4 P; S/ e; L# b( D .default_trigger = "default-on",8 c! [' H; t8 F0 h D; B
},6 a) J5 t8 J7 M" @5 |
{ U- h- y3 v- N/ Z2 C- j" J6 H
.active_low = 0,1 q' y6 H1 J7 u
.gpio = DA850_USER_LED1,# d, n7 n6 \9 N3 I# H. e
.name = "user_led1",* _& p8 n* n2 c" n
.default_trigger = "default-on",5 N g( a: T. }8 ^4 a$ G
},! t2 z3 H2 r2 f' m" b
{
7 Q2 V8 M ?, C0 O# e .active_low = 0,
5 ^- Y( E0 k! Y# n$ Y; R( c .gpio = DA850_USER_LED2,, {) Q* V7 j4 d
.name = "user_led2",
1 Q2 W% c& [' o+ R! X# r .default_trigger = "default-on",' d' E: r; R' X" h4 O& |: D
},
# P& }) C) o! j& U) s {( J$ W7 w8 W3 l" d+ }
.active_low = 0,
% Z' M8 r1 {, C' r5 | .gpio = DA850_USER_LED3,) ]* K% {1 n) E3 T
.name = "user_led3",
( ~2 q' L N( G) F& R .default_trigger = "default-on",) b u% q' d* M( a9 ]
},
2 t: a/ t: U5 l8 M4 H};
$ e* }; z, |' T2 n4 }# ]: e% W& I. Z7 |$ ~2 }3 \* Z
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 f% i2 G, Q* r q .leds = da850_evm_tl_leds,: B, C$ a& f: S( T
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' `" |# l# W" q) r};" V) O+ M R& r6 A
, _) M" C; l6 v$ c
static void led_dev_release(struct device *dev)
8 \* h$ I" o. U. D4 Q" M! t: U{
+ i$ ~2 d1 {& e4 C) ^};( l/ P2 k1 Q$ P
! }) J- m% H0 D9 G( P( U7 r5 Lstatic struct platform_device da850_evm_tl_leds_device = {
0 `$ _3 d8 k4 @ .name = "leds-gpio",; J1 W* w7 j' f
.id = 1,
5 Y2 M7 m3 B0 [5 A0 w3 m/ _ .dev = {+ j0 h4 y4 ?1 K8 s
.platform_data = &da850_evm_tl_leds_pdata,
2 P8 T6 @8 A1 r( I) d .release = led_dev_release, V2 ^, _# t% R C m, P
}
* t, I9 r# ^% V* o+ `* N$ u7 }6 e* d9 F};8 u! g4 W5 a5 n' j% J& [' ?- `
; W- e+ C: L% E+ z& t
static int __init led_platform_init(void)
8 z& s# i( a, b6 U* y{
# `) _ }% F* m int ret;; X5 s- R' A+ l4 G5 l
#if 0
5 D1 d: H% Y: q0 p ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);9 L t* ]6 j8 v& a+ o9 P
if (ret)
! e5 ^2 L% e7 v( i r% @: k, j h8 ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"1 _; N: J& O4 m4 P
"%d\n", ret);4 L# o) n' v4 }- ~( z. Z
#endif
1 |3 @) N4 w! a ret = platform_device_register(&da850_evm_tl_leds_device);
E% M# j% [4 _7 I) { if (ret)$ z$ G: d: m2 w) F7 M
pr_warning("Could not register som GPIO expander LEDS");
5 P: ^5 d9 m s& t7 G; t$ G) g& u else" X! y$ Q% c2 Y, m+ R
printk(KERN_INFO "LED register sucessful!\n");/ J% ?$ o1 M* b3 i# k5 X" c
0 J4 b% | s3 i6 h# V7 f9 l return ret;6 i, M* M @$ M
}
: e6 ~" h6 h8 E, v8 e8 v6 q- A4 N0 b" L7 O
static void __exit led_platform_exit(void)
* b2 \1 }4 ]4 b{
6 n' ~ ^+ W, M% s) U9 L platform_device_unregister(&da850_evm_tl_leds_device);$ s8 l4 Q8 S) q2 p& S; ?( X
( n E6 I+ W3 f- K- L printk(KERN_INFO "LED unregister!\n");
7 y) C1 [, N. L$ C1 F, m}
" K) U- f0 S% w+ P; e
0 H# ?1 m5 v9 n5 v3 m; r9 Tmodule_init(led_platform_init);; G* ~3 s3 X+ J. ~, t
module_exit(led_platform_exit);
& O* `1 p/ R8 V) p* ]. ^8 P/ X3 i# ~: l) s$ Y
MODULE_DESCRIPTION("Led platform driver");9 \+ i B0 `8 c1 Y% `) Z
MODULE_AUTHOR("Tronlong");
D4 T3 W. Z3 G7 g- eMODULE_LICENSE("GPL");- K! _' U. r$ E$ z& r
4 \1 I) O) h0 ~ V' P |
|