|
|
求大神给下面的程序做注解,请稍详细些,谢谢。! C. {, l/ @( p$ a* b& ? C
#include <linux/init.h>
! _( |5 y5 Z! Y#include <linux/module.h>
% k0 ?- w$ f, i$ j#include <linux/kernel.h>
' O7 C; Q. a/ Q7 w- L9 Y1 C#include <linux/types.h>1 c: `% v4 k- G# I/ I
#include <linux/gpio.h>; _; m- H" Y. v) F2 t8 ^: E$ J) ^
#include <linux/leds.h>8 s _& I- X5 N' b/ T! O
#include <linux/platform_device.h>: B3 w+ q- j8 B4 q; e5 y/ Z
" ~/ L6 ~5 ?! R( R7 D
#include <asm/mach-types.h>
! G" A+ \" r( y7 O* X#include <asm/mach/arch.h>
5 [# Q% q) w. |3 g$ E( {#include <mach/da8xx.h>3 x0 l6 f$ n% o
#include <mach/mux.h>
9 e P5 Q) k& `7 B) o/ B! ^8 g# U
#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
$ c" n! g& j5 j8 ?#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)
" s3 W9 M% F9 D- C6 Q2 ~, i3 W) G#define DA850_USER_LED2 GPIO_TO_PIN(0, 1)/ X- z5 Y' T: j
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)" h1 @, i1 t; \4 a" V
3 Y! @. h. b) E g/* assign the tl som board LED-GPIOs*/
/ x- }( F3 F6 z N$ A4 Wstatic const short da850_evm_tl_user_led_pins[] = {& k' l7 X* X- S& S/ q7 v3 h
/* These pins are definition at <mach/mux.h> file */
, m! H/ J$ b4 D# A: [. ? DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,2 J2 D" C+ x% o* ]' r& x
-14 V% |& j: a p, `+ P
};
5 q( t& t6 B5 s( T/ I
. U' u: C; w2 t8 ]( s1 P7 Qstatic struct gpio_led da850_evm_tl_leds[] = {5 _ p: g4 d* {. y
{
8 K* R2 f( S- }1 s .active_low = 0,
, s3 F- F2 t6 \& |" X! q .gpio = DA850_USER_LED0,
/ q" n ]% {- V4 J, ^0 W1 H .name = "user_led0",. q4 Z' F% h8 E3 E4 T
.default_trigger = "default-on",
+ |- N5 S% y" b0 N },) H# y, Y7 ? T n- R& c
{
, S. b V7 U% x3 K3 I" O0 Y6 r .active_low = 0,
3 t8 |: y& K, W) x" @3 D .gpio = DA850_USER_LED1,; ~+ C9 r6 b- ^/ }
.name = "user_led1",( q( M# { J9 d) Y, V5 h
.default_trigger = "default-on",
% ]% z/ ~- i! [ },6 f5 H3 Y3 E4 P0 P1 v: Z
{* z5 X& O- J2 @! R* |) v
.active_low = 0,
3 K3 g+ I ?- j; z1 Z .gpio = DA850_USER_LED2,
/ z/ I* u/ g6 O .name = "user_led2",7 I5 h, |/ Y7 p/ [7 H( ]& v* |
.default_trigger = "default-on",
) t7 J- ?) I. p( G4 ^ },
' B) R; m5 x% ~- |1 K; J C {
& g% m. ]# D* B .active_low = 0,
0 q, v6 d+ ^+ o" P .gpio = DA850_USER_LED3,! z) D2 d; s' G& w" B s4 m
.name = "user_led3",' i: u( S2 p& Z: Y% p8 I
.default_trigger = "default-on",
9 \0 p% f. e+ o# S( d! ^9 c/ E1 C6 L },
5 a( f% J) c# U3 u) H/ @};3 n( T! ^8 X5 u! W5 V/ n7 q2 J7 n
* Z! ~. A* l+ f% c- g
static struct gpio_led_platform_data da850_evm_tl_leds_pdata = {
: |1 M' A& E/ G% S0 z9 K .leds = da850_evm_tl_leds,
6 }$ I Q( e) S2 s$ t .num_leds = ARRAY_SIZE(da850_evm_tl_leds),
' O3 h4 e$ ^( ?2 W' D' A& K, i$ d};
9 c+ z5 |4 f8 g! d! p" m! b" ^
, ~# k7 A/ |/ R. \static void led_dev_release(struct device *dev)
5 d" S3 W4 E2 M; ]4 T Q3 {$ T- a{- h8 w+ s. }, Y% j' ^% J! q
};
: q0 f7 p* F+ k+ h
9 v1 D3 W O3 i* rstatic struct platform_device da850_evm_tl_leds_device = {! x6 M$ t+ \ P/ H2 T0 @0 @
.name = "leds-gpio",
7 q5 v; d% U/ n* |: R .id = 1,
$ Q/ o# }5 H# f5 k5 U) K .dev = {
1 G! R- H, a8 X1 y .platform_data = &da850_evm_tl_leds_pdata,
/ x- O' r. ?5 v .release = led_dev_release,
2 P0 s, }' |# R" _$ i$ K }
: o( c$ _( |0 E7 `. m+ ]};# g' F# d: U' o0 X; x r
( T) A b9 F, t. C0 astatic int __init led_platform_init(void)( G$ B6 X: ?) h! K, {9 D- I" S
{
9 l# Y$ Z4 g7 o/ |1 {. o8 q int ret;! b0 R3 k! f5 c9 G4 ^; H/ T; ?
#if 0. Q6 E6 b+ v; }% Y5 }, h
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);% t. j. x( Z4 i* R. Q3 f4 T2 z
if (ret)' _6 y7 i2 c7 L+ V4 B! Y
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"
( M7 m- D- Z+ a( @: j0 k& T "%d\n", ret);- Q9 p1 A7 \$ E# ~- B& l+ |
#endif/ m9 {! D1 R2 }& Z2 H
ret = platform_device_register(&da850_evm_tl_leds_device); C! {+ g1 ~ J! p
if (ret)
, q0 X* S/ }+ c- z4 K pr_warning("Could not register som GPIO expander LEDS");
: t, Y2 r! a' `5 U else+ ^* [) @( |) |5 Q! v
printk(KERN_INFO "LED register sucessful!\n");
* G6 u- V: m8 L3 ~/ R% Q$ M; e1 u! v' K
2 y9 N# _" k& n- d7 P F( {" E return ret;- `, \* s) |! k3 C7 P+ Z3 W
}! L6 `; K5 `, T( v7 d& `. M
/ W1 R+ T' {" J& Y$ T) u' A/ pstatic void __exit led_platform_exit(void) v ? o& Z: d5 E: e' Q0 D$ E
{
# r1 Q4 F: z3 a1 ~% U/ w platform_device_unregister(&da850_evm_tl_leds_device);' @7 G" ?) ]! J
! e6 I: Q& b9 Q3 z" h9 q% z printk(KERN_INFO "LED unregister!\n");
0 ^! ?7 N0 e8 V9 Z s$ |}
1 e: k4 @: G7 }1 C8 h( k! V5 C" Z* D# c" \5 @1 \- v+ F
module_init(led_platform_init);
0 I1 Z! H5 o( n/ }module_exit(led_platform_exit);
& k5 u1 |1 q3 A' J; ?0 Q b3 e1 W) k% Y2 O
MODULE_DESCRIPTION("Led platform driver");
2 i k8 [ f. xMODULE_AUTHOR("Tronlong");5 I* Z6 N/ K7 B0 I. @: [0 w
MODULE_LICENSE("GPL");; p4 ]: `& y4 `6 b' j
* z2 _8 s/ o. X
|
|