|
|
求大神给下面的程序做注解,请稍详细些,谢谢。7 G1 I8 a5 e2 y0 N: u/ c
#include <linux/init.h>
- v0 `+ y! w7 ~2 {, e#include <linux/module.h>$ Y2 {1 p( H/ U3 l# t. Z% @
#include <linux/kernel.h>
p0 c7 `2 d' A#include <linux/types.h>, \+ W; d. T v8 Y! W
#include <linux/gpio.h>
. {) c+ t( v: k A6 P, v! C#include <linux/leds.h>2 G2 w2 a8 A- P. W \
#include <linux/platform_device.h>
, I) N1 L3 z: p0 ]) L
" {: @" A6 R! |) w z, a+ B" X! W#include <asm/mach-types.h>
' a7 J/ ^0 `4 ?* [#include <asm/mach/arch.h>
; T7 l- E2 q! O Q% ?, P#include <mach/da8xx.h>* e' ^. S) c. f8 m# `1 Z
#include <mach/mux.h>0 g# j! J% N; Z2 a+ e" c9 [1 v; j i
7 q5 r* W5 E/ T0 K, Y K#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)% I4 J& k% @" w* Y& F# Z& a! p
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)4 j+ R; n8 K: z; _/ Z( L5 [9 q. |+ J
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
; ` h- l2 n3 w3 m8 D3 z#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
0 I9 \. w1 P$ i6 R, \4 P! T. y6 ]6 ]! Z& A+ V6 d
/* assign the tl som board LED-GPIOs*/
" u% P' P' o astatic const short da850_evm_tl_user_led_pins[] = {, \9 e4 i( q" s6 U) U
/* These pins are definition at <mach/mux.h> file */
2 B F, d; j' N DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,& ^# ^) h4 u+ S! ^( m; I
-19 F0 {; I) K+ t3 J3 U
};' D4 W2 [- j$ W/ |* j* q
; @' |8 U1 ?* b) `- Cstatic struct gpio_led da850_evm_tl_leds[] = {
8 C- y2 E! ~+ d' I9 m! D+ ]) e' ? {) |: @( K& y. u4 O- R/ e0 C
.active_low = 0,
8 m" v' L6 Z' q, {8 @. T2 R .gpio = DA850_USER_LED0,; n( t. c$ B" `3 }% z* f3 Q- E- m
.name = "user_led0",8 q) R- E, |7 K- _ k, r
.default_trigger = "default-on",
! }1 B" G7 ~8 q% a" ?9 v. `( e },
9 T! \: G* |7 X3 j { W' \: j8 i3 m. r! M* n
.active_low = 0,3 C( v9 d: ~9 M% X2 p* n" M# d9 Z. J! ~
.gpio = DA850_USER_LED1,
5 J" O. D3 w0 B .name = "user_led1",) s9 j5 z. ?. s
.default_trigger = "default-on"," N8 |; w$ d0 W% s; i- p& C9 O4 T
},$ N8 _8 ? B! N5 @) V ^" {
{' \: I0 A3 U9 {8 L# O
.active_low = 0,# F, N/ |7 k6 j* j0 N
.gpio = DA850_USER_LED2,6 W8 n8 r, k' X! s) z1 N
.name = "user_led2",
; L& C# _$ P v4 l- p7 n .default_trigger = "default-on",
( U; h2 l% [" X6 { }, [; t7 o, L) F6 K# b
{
1 i: b. P8 R' _3 \' f7 @ .active_low = 0,$ `/ U8 ~# A" @0 L* d
.gpio = DA850_USER_LED3,
9 X* [# n! v4 Q' G .name = "user_led3",
, t3 Y2 V L1 q; w! b' s, H8 c3 O .default_trigger = "default-on"," x3 c2 I, j8 X: v& K& C- ^9 Z
},4 X* A; L) _, ?0 P' f$ }: T0 k& Y
};: j; S+ W# J. i5 h! c' S
; A5 n$ ]5 {0 X/ }+ lstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
0 Z" t0 c; j: _% O4 l* | .leds = da850_evm_tl_leds,
. ~# r8 W4 q) L5 w; Y+ U .num_leds = ARRAY_SIZE(da850_evm_tl_leds),1 R) | v1 M0 Z: o$ h( I3 I( r/ i0 }
}; V) ~6 U3 F( M
* d# a7 B: K) y; b" p. s6 Q1 P
static void led_dev_release(struct device *dev)0 M& V) P" g( ?; N* W
{# V. R$ w$ C6 I' E* g# v* h. G
}; P1 N, W5 S* k' _8 j* K
' M0 B. X0 r# k/ {1 l3 sstatic struct platform_device da850_evm_tl_leds_device = {# v. s" a# x5 R- M% V6 F/ {
.name = "leds-gpio",
1 T) H, U1 I* Q; e/ O, K .id = 1,1 q5 G7 i3 u, n( ]1 `2 ]
.dev = {
* G. t4 }- h& j! `$ F# g2 h3 F .platform_data = &da850_evm_tl_leds_pdata,
8 A4 k* M% W* c .release = led_dev_release,
5 C ^& T( y2 T; q7 W M }
0 i* _/ l* ~" o3 N1 H};8 P; l0 }, d0 p0 u; K
" }+ j& k! c/ Y% p# w6 m
static int __init led_platform_init(void)% K) |' d7 S& c' F
{" W3 F8 k" E2 D* C
int ret;: Z/ Z: _7 L/ x2 [6 A7 q" J2 ]
#if 0$ k- @( x3 F+ l
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
2 m. q2 [9 `7 b if (ret)
# @5 K, q* V6 t6 S pr_warning("da850_evm_tl_leds_init : User LED mux failed :"2 _; g+ p' }# n* o& |, x
"%d\n", ret);% C/ [" K, u- b* [5 R
#endif
7 H) E8 `- @" r) ^, o+ a ret = platform_device_register(&da850_evm_tl_leds_device);: ?" Y1 [* c" t" d; U
if (ret)7 E! |8 e( B0 C
pr_warning("Could not register som GPIO expander LEDS");1 h p3 s$ ^) N R1 v
else1 \; x8 Z9 F5 x m
printk(KERN_INFO "LED register sucessful!\n");2 j5 V: ?! ~8 m. Z5 e$ ?
9 e" j4 }3 C1 u. j* b6 i# [ return ret;
' W4 L: I/ Q8 W! v# Y% Z1 P}$ B" @; i! A# V$ u. t' j# h7 a1 S
+ i7 Y* U( y$ M$ m
static void __exit led_platform_exit(void)
0 V4 K/ Z9 p6 y6 R: `* U{
& @' K/ q$ ^3 }! j platform_device_unregister(&da850_evm_tl_leds_device);
9 V8 n2 j, R$ c. D" o9 i W' X$ W: F8 l$ E$ g
printk(KERN_INFO "LED unregister!\n");; E$ T: |4 F' h3 R6 Y
}
: q! _& ^8 _! x* N+ M5 l
6 K8 N8 H( E2 [. s8 Wmodule_init(led_platform_init);
( k$ V3 j; M9 t) Tmodule_exit(led_platform_exit);% V( d% r3 U; [" Z" J
7 u# ~% g' d7 S9 z% J4 h" r$ U
MODULE_DESCRIPTION("Led platform driver");; M5 U" d) j" M* S
MODULE_AUTHOR("Tronlong");9 H3 G+ a, [ R' L- v6 p' A j
MODULE_LICENSE("GPL");
: s# `) q1 J' G+ e- [4 T" M E$ {6 }) ?% p
|
|