|
求大神给下面的程序做注解,请稍详细些,谢谢。
. W c1 {5 {( ^8 Y; E' e0 Q#include <linux/init.h>
0 t$ B+ u2 D0 Y3 D9 N, D#include <linux/module.h>. _' L1 N2 `7 m/ w
#include <linux/kernel.h>
' B! a' n( J- K1 t7 S' A#include <linux/types.h>
v6 q7 C1 \: x4 \* L#include <linux/gpio.h>
* k. L; `. J. u1 p#include <linux/leds.h>0 w0 f% k: H1 V& }" x) t p# R
#include <linux/platform_device.h>
; R- F+ D, S- }- `3 L0 W7 _% I" U: Y
#include <asm/mach-types.h>
+ W# y$ j. y7 d: n" G4 S7 [7 W#include <asm/mach/arch.h>
# x& B3 E# x: x" g4 ?0 ?' X( P#include <mach/da8xx.h>
. l: z/ x1 o8 F+ t#include <mach/mux.h>
$ _ |0 C5 R" C3 M/ m" j
b' ?# u3 s+ X; H# R#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)8 d7 e# C, ? p/ u" [- N
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): n/ Z& ?5 P) N: g4 j9 ?% P1 l- \
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)
6 {7 C- G% w0 \2 a6 k5 ]#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
: W8 p* T6 j. N9 w* \9 d7 E8 J) e# B
/* assign the tl som board LED-GPIOs*/6 e% E h0 l) w& H& R, A& |
static const short da850_evm_tl_user_led_pins[] = {
3 U8 R% ?5 p* |5 y: g /* These pins are definition at <mach/mux.h> file */
5 r, b7 `6 K4 ~8 p& @% n/ ]1 t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,
. D; ?* ^) Z8 l( w/ D( l. [7 c! n2 | -1
2 \) j- B. Y- X5 ~% i' l; [% X# @};
3 @' V: E l# U1 M$ c4 u/ d+ Z: b3 T& h, p1 b4 F4 _
static struct gpio_led da850_evm_tl_leds[] = {3 l8 B2 y+ T# w. o8 L: `
{
9 w v/ x0 w$ G" B4 i .active_low = 0,! _1 U1 h" Q9 S) k" a3 G/ v
.gpio = DA850_USER_LED0,9 a) c7 O; e n7 z( o* m3 g* h
.name = "user_led0",( a2 t' V9 ]. C6 O* o% K
.default_trigger = "default-on",! _. L' P. D) G; ] n9 I
},7 c s6 j# j- X& c% `* L; n
{
) k+ K+ M. m5 a/ w8 V. m3 U .active_low = 0,& }+ z/ Y) h/ Z: c& H2 C& X
.gpio = DA850_USER_LED1,
7 J' R- W! j! D9 V. X8 u .name = "user_led1",
/ X9 v$ ] q9 L+ T& F .default_trigger = "default-on",
@4 t: X0 N2 D" M7 e },
! o- v6 `" @- [ {
& {- \& r9 L2 S( F' @, Z6 ?( D$ _' } .active_low = 0,
& @. A6 [6 w; e$ w( G+ F, [ .gpio = DA850_USER_LED2, E3 P" A# m' {. G+ v* Y5 ~; q% [+ W
.name = "user_led2",
5 @* V" e5 }5 G/ z+ F) _5 w$ q .default_trigger = "default-on",
! A! K) \; K: o- S$ s9 f3 _ },
4 ?3 R+ U- y2 F/ c: Y7 } {8 Y* p, }( |3 v; v, F
.active_low = 0,
" f6 n. w; r$ `6 Q( ?: H .gpio = DA850_USER_LED3,1 H% a- C. [9 Z2 B l
.name = "user_led3",& ^- R" U. ` S* P% k' y
.default_trigger = "default-on",
( u' l/ y( m) Q0 i A# j },
* J3 W- `" J3 o9 [};
W+ c q; x' P2 }5 U
1 r; D2 _! f' v2 x# M1 [1 Mstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {2 k+ l% L% ^5 h! Z
.leds = da850_evm_tl_leds,: t2 T0 t0 L( s- r
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),7 O) M. t2 T E4 M
};7 M: a/ F5 V# { l" y( z$ h
# t7 v0 U/ \0 C+ ~* ]" Astatic void led_dev_release(struct device *dev)
6 S, S) L% a; @" D% @{9 Q! q/ {9 u: k
};
' {& b3 `: s: Y5 R) t0 k; G: A" k! k. u; q. U# M# P6 o5 Q
static struct platform_device da850_evm_tl_leds_device = {
9 v5 ?9 y' v# G. Y) p+ G1 G .name = "leds-gpio",) o1 h* y+ z; `: G& p
.id = 1,
* \; D: c* q" Q' f; k* ]: z: O1 W .dev = {( p1 r }' _* j
.platform_data = &da850_evm_tl_leds_pdata,; d% `+ T7 E9 N
.release = led_dev_release,
9 u0 Y6 ]' q9 s* y4 D& p }
# _ O1 y* @7 @};- P' z5 F5 M; g! a8 U8 w
% K+ D0 |0 s" o" ] V7 [static int __init led_platform_init(void)
% g+ E3 e) G) ]{
+ i& W1 o p& h( t int ret;
: O3 g% j# |, h0 X. `#if 0( P6 Y5 }' O! G& ?
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ S& e' ^! J9 N1 i7 o- _$ `( q if (ret)
8 y }2 R J2 K' N) `0 F( z- s pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
0 ^, w/ y, f" s |1 X "%d\n", ret);
5 P- A$ {8 _5 r! k8 i! m4 }#endif
" y1 D7 g! _) `. e; \8 t ret = platform_device_register(&da850_evm_tl_leds_device);' T7 w6 K! l5 j) X5 z' ] T$ r
if (ret)
2 X3 {1 w' @% z3 Z pr_warning("Could not register som GPIO expander LEDS");
" V2 d t9 h; |( _ i6 F+ K! Q else
% s3 ]6 }6 U0 n6 B. F0 U% q5 H printk(KERN_INFO "LED register sucessful!\n");
1 ^3 ]2 n k: [# e; e" P: S
: T6 s$ s0 ~, o& i$ j+ V return ret;" T7 t9 j& Z# [# D6 [" s
}9 V1 F$ X( K! @( I: Q
& y; T% i _, K* s) R
static void __exit led_platform_exit(void)
7 L" ], _5 J4 a! B0 \* ?9 o{
3 w3 X: P. c, c platform_device_unregister(&da850_evm_tl_leds_device);
5 N }5 R2 R. a- b0 w$ j0 L6 c& r# v" R1 v
printk(KERN_INFO "LED unregister!\n");$ J& k) q0 ?. Z" A
}7 O1 ]! d9 |6 a! H8 Q7 D1 n2 @
& ^/ O }, Z3 C5 [& N( f
module_init(led_platform_init);4 O5 K- `0 X) s& V" P4 N
module_exit(led_platform_exit);
! g6 u4 v! d0 f1 A
! s' J% z) _) V4 H. z/ G# OMODULE_DESCRIPTION("Led platform driver");* z$ }' G# ^9 _) c) j! L8 g- v
MODULE_AUTHOR("Tronlong");0 ?1 a+ M f8 r
MODULE_LICENSE("GPL");$ F- r' ?% r6 [7 y F! H
+ |" a. w) c/ L+ i |
|