|
求大神给下面的程序做注解,请稍详细些,谢谢。5 K5 ?% l& Y- K: {" I, l
#include <linux/init.h>
0 ?! m! `* P' y9 f0 K8 ]4 K3 Y#include <linux/module.h>. Z5 i: z' @5 v& j* }* h* i) M
#include <linux/kernel.h>
7 K( [' ~9 a/ g, ~' l3 }#include <linux/types.h>
/ H7 @0 A4 u- }/ t) {#include <linux/gpio.h>
3 t/ Y* m- ]: l% |#include <linux/leds.h>
/ U9 G/ D9 n8 A& q#include <linux/platform_device.h>
2 i4 T& m$ a8 S; H2 r5 ~, C) |/ V. m$ O; X( g! h) t( c
#include <asm/mach-types.h>
4 S/ X0 M K9 m( ~0 T- D1 g#include <asm/mach/arch.h>
7 I5 ~, L+ M' o#include <mach/da8xx.h>
/ x/ w& j, \$ q#include <mach/mux.h>" h2 A9 [% N# Z4 L* \( t5 c; }, B( ]
& h! |6 O) a: k4 S( F
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)2 p9 C1 K) y+ B$ a/ Z% b. n
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
5 [0 f7 J; B) u#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)2 p( q& Q: Y! V
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)$ g+ ?+ d9 J+ ?, u1 R3 L
( f0 ^- i* [; o6 o/* assign the tl som board LED-GPIOs*/
! Y- Q- `& C. h+ u* f( [static const short da850_evm_tl_user_led_pins[] = {
% ~" w9 v. y# _ M: f /* These pins are definition at <mach/mux.h> file */
& y1 U% _# w3 }- E& V, Z DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
2 k7 W+ o, S1 D% E4 Y' w -1
' D! k3 o0 h" C/ d3 e5 ]};) @! u, s/ E: q6 r: F2 b8 k" b
. E3 a: c0 x3 ^
static struct gpio_led da850_evm_tl_leds[] = {6 Z2 w! l+ X) @7 [+ W! ^) t# n
{7 S, ?# `! o" B3 s) T- O
.active_low = 0,! c0 d+ c' h* {4 q) s' U
.gpio = DA850_USER_LED0,
" b$ H$ M3 O$ }7 J .name = "user_led0",3 h, f+ R _/ x( i4 V- `
.default_trigger = "default-on",
( g* {8 j( ~# }5 B },
/ Y9 C& ^( U. t. ?4 i {
2 W2 G# K' {3 n% w# Y/ F .active_low = 0,
3 p3 Z' Z* @, t, o8 @ .gpio = DA850_USER_LED1,
6 a7 E8 r: L8 n4 S& J! {7 E# [ .name = "user_led1",* D+ @/ \ J5 N) v- M6 o; q2 r+ F
.default_trigger = "default-on",
2 @7 D+ f' q5 I- @2 I+ i },9 O. [' {3 G1 S+ K5 D2 k6 B
{
7 s6 ^ E0 w+ l .active_low = 0,
4 H4 b8 F: a+ ~, l, r( G .gpio = DA850_USER_LED2,
- B, \0 n6 L) G .name = "user_led2",
; ?) V4 i2 @# P) i .default_trigger = "default-on",: g5 x% J6 j% l! u
},& ~* c. V8 c, N
{
. m, f' [9 v, @1 U3 _7 R) e .active_low = 0,9 A# ~7 m5 r- p& D! x8 n/ Z
.gpio = DA850_USER_LED3,7 W9 J2 E* L& ~: t6 ]
.name = "user_led3",
3 E) d8 q. |5 Q, k7 \+ B5 t .default_trigger = "default-on",7 R/ p) w. J- v! N
},+ X/ K8 \: U1 s! Y( v9 `
};
# s* O2 J K9 V& p/ r( ?+ j1 x8 w1 C6 }6 o v. s5 w
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
1 {7 K, _2 A. l9 M2 L0 Y9 U .leds = da850_evm_tl_leds,2 q; L- I# w( u6 z$ R' Q7 D0 } I2 ?
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),0 q# v# t4 _( w& ~* E! E
};
6 h# O# N; A- A0 ?& |
" ~, z0 n; @4 U8 gstatic void led_dev_release(struct device *dev)$ e; ]0 r( v$ g& B
{. f1 d4 T. h( b$ a: i
};
$ Z5 \2 s# L' [" G( y
( Y+ X+ r. n/ T u, Tstatic struct platform_device da850_evm_tl_leds_device = {
7 p9 e3 c( Q0 z .name = "leds-gpio"," J- N: P" c% T3 Z1 _
.id = 1,4 u @& i! I) I) F
.dev = {6 r; h9 W& k( r' l
.platform_data = &da850_evm_tl_leds_pdata,
* _1 i) ^# U: Z4 _ .release = led_dev_release,
( E; L$ Y# [1 u* F } h# f& u2 e, R. N( w) F2 ]
};# j5 M! b4 P; m/ G+ n7 J
( Q f! r0 l2 g& {
static int __init led_platform_init(void) q% Q, i, P0 x% o
{& v h+ x. S" b# J( R. u
int ret;
/ U8 a+ e8 T! i# Q#if 0" ]8 r6 o, A3 J2 Y3 `
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
8 F, p. Z. O& y if (ret)% \: J2 ?8 W9 R/ r- \
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"9 I& h. _* @+ S- @% p4 H1 e2 {( M
"%d\n", ret);7 E4 E4 c/ `5 y6 N7 O5 ?, Z
#endif% y2 E3 V4 q8 V4 {0 v+ Q% w/ R
ret = platform_device_register(&da850_evm_tl_leds_device);
5 b [9 a; i) t! m- z if (ret)
$ z: I! M- }5 C' { pr_warning("Could not register som GPIO expander LEDS");
5 L+ e% t* V, G: E5 v else* }4 w0 ?9 s a/ u
printk(KERN_INFO "LED register sucessful!\n");
& b9 y5 @' v \$ f) k6 e% G, ^6 F- h8 e* V- U5 C
return ret;0 [ W5 Z$ m/ t1 ^$ @6 O
}& @; c$ `$ N! w; [
% F. A: ^* h) d. h- b' H; K
static void __exit led_platform_exit(void)
, U8 \- G$ K# k5 `8 H{8 m V: I$ I% C( V5 P( Y, u! S
platform_device_unregister(&da850_evm_tl_leds_device);2 E' h4 @3 R/ t) k
8 D- L7 k4 I' c& _ printk(KERN_INFO "LED unregister!\n");
( l) d; U2 C* F; f" @}7 i# ^1 Q: {4 m8 j# }3 T H
. x! O/ @/ o+ P" t9 V: V6 ~+ W* Smodule_init(led_platform_init);; L' Z! @& G9 B* \+ p4 {3 p1 S
module_exit(led_platform_exit);
1 P0 w4 b6 K$ [4 m
a: t% a$ L. }( y/ r8 pMODULE_DESCRIPTION("Led platform driver");8 I+ D, L% Z( o" @8 b
MODULE_AUTHOR("Tronlong");
3 q' y" a2 _; Y& L" r* F: y! R, P( vMODULE_LICENSE("GPL");9 ~2 @' f6 S0 W W
( Z, Q' x: W/ ~# a# R4 t/ \ |
|