|
|
求大神给下面的程序做注解,请稍详细些,谢谢。
5 o# v* R1 ^# [6 X! V. H#include <linux/init.h>
" q' J# l _" e5 I2 c#include <linux/module.h>
0 Y* I7 J9 f9 b a& y( v2 Q8 S#include <linux/kernel.h>5 g- F0 H; c; o& J
#include <linux/types.h>' B! k* q p. }# E+ L Z; S, Q
#include <linux/gpio.h> p" e+ r, Z n
#include <linux/leds.h>3 P$ u. @$ y/ N# G9 }4 s% X! \
#include <linux/platform_device.h>
: ^" n7 P8 j4 V& Y
- ^( ^9 K+ C* q _& B#include <asm/mach-types.h>
. h" [4 V; c& V' J! d#include <asm/mach/arch.h>
7 @4 K: G: T7 Z- T' Z' {, v#include <mach/da8xx.h>) g r5 M, d; d9 w5 G
#include <mach/mux.h> P" j1 t7 r$ Q( V5 {% {
0 j8 U! ]3 O# I" U. _+ ~#define DA850_USER_LED0 GPIO_TO_PIN(0, 0)
. n5 \; t6 [3 F$ N3 \#define DA850_USER_LED1 GPIO_TO_PIN(0, 5)8 `5 H% x6 P( [
#define DA850_USER_LED2 GPIO_TO_PIN(0, 1): f2 {+ R2 o8 T) ?0 T" m
#define DA850_USER_LED3 GPIO_TO_PIN(0, 2)
; R7 p) ?$ R' [9 G
2 \# V1 _$ S3 I) y- |0 s; F/* assign the tl som board LED-GPIOs*/
% l J% I; Y, ], _static const short da850_evm_tl_user_led_pins[] = {
4 l7 F# R' i8 ]+ ?2 \ /* These pins are definition at <mach/mux.h> file */
7 n- \% t5 `9 _" V, t DA850_GPIO0_0, DA850_GPIO0_1, DA850_GPIO0_2, DA850_GPIO0_5,! }6 s. p, S ~
-1
+ Z; I3 P8 k; N: |* s};( M( n4 x, _. Q$ s# C
2 H. u0 H+ a1 D4 ~static struct gpio_led da850_evm_tl_leds[] = {& X/ u6 s5 o: M( R
{
8 H% _ k/ F7 u6 E .active_low = 0,' n* C! P5 p/ N! u g6 k
.gpio = DA850_USER_LED0,! |& j4 m, t/ ^, D4 q
.name = "user_led0",
9 h* G9 R+ i2 ?+ Q' } .default_trigger = "default-on",) B( f% ]& n" m8 r4 M _
},0 o% t. i) y( H: u4 @
{% m6 E9 C1 y4 [; u9 p( g" U
.active_low = 0,1 O7 \, s/ v x% Y" u8 z- F# h0 a
.gpio = DA850_USER_LED1,5 G8 D, Z$ y: h% m; b2 Z
.name = "user_led1",
$ T3 }0 o( N7 W+ r' ^) c .default_trigger = "default-on",7 X8 k0 N1 f& f5 q- Y) n& W
},. b, W H" n% a- S; ^
{
7 q2 k& C9 t& n. A" [ k4 R5 D% x .active_low = 0,1 `5 _# H+ W7 P2 v
.gpio = DA850_USER_LED2, n$ \7 v, c1 ~# v$ ]& S# {% a
.name = "user_led2",
, W3 o+ D ?( S/ u2 t# o .default_trigger = "default-on",+ F3 @5 Q- {+ n# M9 H
},
S1 n! k& \% s/ i8 [ A$ N {4 k2 L) Y O0 A1 Q( O9 j# ^
.active_low = 0,
& i, k" @8 M* e% U) G. [ .gpio = DA850_USER_LED3,
$ C0 N/ {% \6 v% ] .name = "user_led3",
- K9 |6 S: ~; K .default_trigger = "default-on",$ @: D: u7 R3 N5 }$ E; P, ?/ J
},
, u' |$ o* Z) v9 g. o! z) e};
8 ~& q9 Y# _4 n2 r1 V. t
8 o; f0 e/ L1 j* Z' Sstatic struct gpio_led_platform_data da850_evm_tl_leds_pdata = {3 }# Q5 \; }7 S$ `- d
.leds = da850_evm_tl_leds,$ g& j! Q& f" M8 `' S! j
.num_leds = ARRAY_SIZE(da850_evm_tl_leds),
. `) Y7 L; L5 A, f' s/ ~};# ~! z: H- {) U
' N$ s: M: p, |4 S8 c
static void led_dev_release(struct device *dev)
. V' ?6 l3 t3 P& `% k( U3 x{
- j* j R O- |- Q+ V};
, z: { G1 D% _8 G$ l9 m' F4 U5 P7 W, Q E* R; a
static struct platform_device da850_evm_tl_leds_device = {
2 b* y) o( R; a' M- K .name = "leds-gpio",
6 X5 l' J3 O, |% F1 L" J .id = 1,
# U8 w _/ @( g: f .dev = {
! H6 T7 t- }8 ^0 Y .platform_data = &da850_evm_tl_leds_pdata,! F- a9 ^- Z8 z: G
.release = led_dev_release," Y7 Q, V0 c2 h
}
3 r z/ d9 y P2 V};4 d) C$ t; |. E2 j+ \( y
( r, y6 w& V8 F) O6 ^+ \8 istatic int __init led_platform_init(void)
+ ~( B/ y3 |8 w o" t' H{
6 M7 k8 {! {% N9 U int ret;1 n, ?2 _. R( `6 @( D' X
#if 0 ]. O4 E$ c' {( f" K; ]
ret = davinci_cfg_reg_list(da850_evm_tl_user_led_pins);
/ W$ a! C& |! V1 W if (ret)0 S) w$ A2 B' I# C
pr_warning("da850_evm_tl_leds_init : User LED mux failed :"5 ^( K c* p' p" J6 {% W# d4 p1 {/ w/ ^) s
"%d\n", ret);
" n5 S" z$ d& K, @#endif0 r) S9 u& y( ^3 A! e7 ?5 }
ret = platform_device_register(&da850_evm_tl_leds_device);
% n K# p! f% F3 J, e' [: x' G& l- T if (ret)
9 G [. M; o! Q# c pr_warning("Could not register som GPIO expander LEDS");
2 k& k4 \$ |# x1 m" s: l6 A else5 D$ K3 k M+ ]; L9 ^5 _# v8 a
printk(KERN_INFO "LED register sucessful!\n");
7 y! Q4 _- _# {' ^: e2 D
6 z' H+ j0 H0 w0 J3 ^4 ^; q- t return ret;
8 F0 p- ]: @. Y r& v}: `. G! j5 Z$ r m/ q% l; E
: ?$ }8 w6 s0 A( t- y8 a$ t( Rstatic void __exit led_platform_exit(void)
& K* C: I" g7 D3 e{: R+ h$ ~ m" x& |, X" k
platform_device_unregister(&da850_evm_tl_leds_device); ]6 W2 J$ V' i9 X0 e
2 D: \8 _8 n; ^5 S' ` printk(KERN_INFO "LED unregister!\n");0 m( y i& T0 |
}5 ^! ?0 D0 n/ ^, H) P" e
- I: [* e+ m, Y4 dmodule_init(led_platform_init);" W! Y* f C( z( F! D, F4 L
module_exit(led_platform_exit);* u! \! L" M$ \; t; }' I! ?: a
3 O: e: Z0 v7 }) [ L& J# d
MODULE_DESCRIPTION("Led platform driver");/ F2 P. R6 F1 \, v3 c# ~+ {
MODULE_AUTHOR("Tronlong");
/ }- O% q6 E: n/ F# h* }/ QMODULE_LICENSE("GPL");, h: g& h$ b9 x
7 T8 l5 Y0 f0 g! \, x |
|