|
|
求大神给下面的程序做注解,请稍详细些,谢谢。- n' X- m1 q! w! @ _6 H$ t
#include <linux/init.h>
; F j9 W: G' B. ^1 w0 P#include <linux/module.h>8 y! X4 ]. F" P$ J8 Z9 Z
#include <linux/kernel.h>& u5 `* @4 l& L
#include <linux/types.h>
l x9 u2 M2 d" |; \2 W1 G" e1 ^8 E; h#include <linux/gpio.h>
* m! v5 t2 ^- [9 x2 d#include <linux/leds.h>
) O/ o1 ]; [, ]#include <linux/platform_device.h>% R' V4 \. F2 p1 B& J
/ a: ]5 ~' K# s2 l6 x#include <asm/mach-types.h>
: _ t7 j( ?. e, f#include <asm/mach/arch.h>+ T/ y' R, w W. `) `
#include <mach/da8xx.h>
) f9 Q* u+ D$ ?6 a#include <mach/mux.h>
|+ h4 z0 }& m
( r1 p% }/ P+ A2 h9 H9 p#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)# J$ Q& \* L7 P; e8 d: Y' Z
#define DA850_USER_LED1 GPIO_TO_PIN(0, 5): ?( I a8 O$ m" I# U3 y& g$ W
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1); [/ p5 n5 P. \3 |
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)- O1 s6 `% d) ~. V
3 U% Y; v$ W+ W9 l8 h8 M+ P9 u
/* assign the tl som board LED-GPIOs*/
! F" d% m& q, d8 s! L, K& Lstatic const short da850_evm_tl_user_led_pins[] = {
) ^+ W9 u9 R v/ E /* These pins are definition at <mach/mux.h> file */! i6 y. M8 _% G9 L' |
DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,. n8 D6 D2 |; C
-1- d/ P4 @9 e2 J
};
: u$ P7 H ~, }' N& c8 {2 h/ {8 `& Y3 \" L& I5 D
static struct gpio_led da850_evm_tl_leds[] = {
' Z; S/ r7 ^9 {0 m {" K [0 ^! u9 ^/ K
.active_low = 0,
5 h. ~8 {5 T; W* N/ }- _ .gpio = DA850_USER_LED0,2 V! H( z" H& p) A) J- ~9 o
.name = "user_led0",
: N6 t% v* F4 g) Q" A5 } .default_trigger = "default-on",
9 `5 W9 W% S$ b; m* V% X j4 y7 a/ t },2 u7 F. x. G" Y
{
2 {. X* W# L" N' X' D9 j& C .active_low = 0,1 Y0 B9 A5 c N% d
.gpio = DA850_USER_LED1,) B/ E' p0 r* i$ v
.name = "user_led1",
2 k' E8 D* E. ]# B1 P/ g. i .default_trigger = "default-on",
& L# M; w, u2 N0 m0 P% w },, I4 ]" g! Y1 |
{4 Q3 K: |! g( j4 R& [; T. t
.active_low = 0,: q, `; J1 O9 Z& e- E
.gpio = DA850_USER_LED2,+ J& S; b, z# |! S: t4 G* A
.name = "user_led2",0 J+ Q7 ~9 G* k, T8 Z- I6 p$ o
.default_trigger = "default-on",* W0 K& ~- k; n
},
0 P5 {4 e7 A' G: E {0 T2 M5 ?+ \2 L- n O* e3 N Q
.active_low = 0,
- Z* \8 `5 l/ ~6 m$ q6 B .gpio = DA850_USER_LED3,
" R% B1 d3 ~9 {+ a( d# v6 {4 q* P .name = "user_led3",
/ w$ R1 h0 ?, ^& b .default_trigger = "default-on",
( S3 b& ^. H: y8 { },
6 i2 }% ?2 X5 o0 T: V$ v};* f, ?/ M1 R3 L" t. J0 }
2 u0 T" ]* v) F/ j5 |- b
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {9 ^0 @1 W3 f. \$ X
.leds = da850_evm_tl_leds,
. @3 E) U. o" b3 W5 V( ? .num_leds = ARRAY_SIZE(da850_evm_tl_leds),% w6 y7 m' b, R2 R# r
};
8 ]) L# t* T; t3 ?% A( h% K6 U% w. R4 V4 |) J, o9 j* Q
static void led_dev_release(struct device *dev)) h+ s" L/ {% Y% l. i# J3 ^) ~
{
7 X4 Y6 T; B4 |/ U/ S+ C$ m};2 T; v% S& v& q
" \" _- g0 ~* U; i t4 hstatic struct platform_device da850_evm_tl_leds_device = {2 O4 v! o' f2 S! n2 u4 G7 a. g6 a
.name = "leds-gpio",; M, V+ U, g0 e; v
.id = 1,4 f2 J( Q% `: D2 @# m
.dev = {
1 H9 |! k( d/ Y5 C3 e2 o/ x* p .platform_data = &da850_evm_tl_leds_pdata,! t& k/ X, ?" J v; y* j0 i
.release = led_dev_release,! B& @8 |6 G1 U; Z: V4 Y ^+ s
}
/ G$ [/ m Z' L' f};( r/ R0 V) T; ] @ D# s9 U+ x
% [, } B0 ]$ z$ D8 ostatic int __init led_platform_init(void), ^' w0 m/ {. ~. S
{- a+ t2 @2 a( F/ x m! L! U
int ret;! g' t) v# R, _1 B) {+ M( [% k5 }
#if 0
) I$ [9 m+ O. C' {/ }3 | ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
& g; `, I" \6 K+ A' N% ? if (ret)
U5 Y/ ?; v$ }) T7 K- ^ pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
5 S8 l* T8 H8 X& L9 q3 v "%d\n", ret);
/ A- V, M# e: E) n* h" D u- P#endif
; w8 {* \. B( I ret = platform_device_register(&da850_evm_tl_leds_device);0 h- `6 c9 f! r( s# ]
if (ret)
8 T$ t; E3 t: v. C' d- m pr_warning("Could not register som GPIO expander LEDS");
) E3 S3 s1 s( N/ ]- [( a else
! q6 g$ _) _0 x' f% R" g printk(KERN_INFO "LED register sucessful!\n");
5 h9 ?0 Z" N/ t: D3 O7 U7 A4 k1 X" `2 D) F7 y# `
return ret;
+ [+ \# Q P0 r5 X- ]}
( x! x1 r/ t% K. b5 p! E S5 c' U; g$ q# H6 U
static void __exit led_platform_exit(void)) a6 r) q+ I* ^! Q1 R9 A
{
8 _& W( T# E& L/ V* k8 q platform_device_unregister(&da850_evm_tl_leds_device);8 E" o9 V0 Y! c s4 c
' |6 `. a% g, W5 D/ o7 e
printk(KERN_INFO "LED unregister!\n");% e: m, Q. X+ s' Z X- Y
}% k3 D; E# r" H. j- K# B9 d
: a/ C* w, U k6 {5 R2 E+ u
module_init(led_platform_init);
0 v2 y+ G1 c+ ]) D$ F7 H+ Zmodule_exit(led_platform_exit);
# A1 s9 D) k/ S- x' b
/ _* B0 @5 F+ W& c" ~1 z" }MODULE_DESCRIPTION("Led platform driver");
+ w$ t) B2 s. {MODULE_AUTHOR("Tronlong");) f1 [8 Q/ ~, ?% @9 D
MODULE_LICENSE("GPL");
! j7 Z' }8 E( c$ B- N/ e$ _& D3 K4 P( p/ g# }- K+ `! t2 ?
|
|